C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

overloading: reference vs. lvalue-transformation

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Thomas Mang
Guest





PostPosted: Sun Jan 23, 2005 1:16 am    Post subject: overloading: reference vs. lvalue-transformation Reply with quote



Greetings,


I start this thread after a discussion in comp.lang.c++.moderated.

Given this program:


void foo(int);
void foo(int const &);

int main()
{
int i(0);
foo (i);
}


Comeau and GCC 3.3.1 complain ambiguity (BCC 5.5.1 picks the first, but that
must be wrong).


Calling the first is lvalue transformation with rank of exact match, calling
the second is identity conversion with rank of exact match.


13.3.3.2/3 says:

Standard conversion sequence S1 is a better conversion sequence than
standard conversion sequence S2 if
- S1 is a proper subsequence of S2 (comparing the conversion sequences in
the canonical form defined by 13.3.3.1.1, excluding any Lvalue
Transformation; the identity conversion sequence is considered to be a
subsequence of any non-identity conversion sequence) or.....


My reading of this bullet is that it pretty much clearly says the second foo
should be called - because of the part "the identity conversion sequence is
considered to be a subsequence of any non-identity conversion sequence" -
independet of the fact that the non-identiy conversion sequence consists of
only an Lvalue-Transformation, since there is no word such a sequence will
become "graded up" to identity conversion; it still remains officially
non-identity conversion.

My questions:

1) is my reading wrong and the 2 compilers are correct?

If yes, what part did I read wrong?


2) If my reading is correct, was this intended behavior and the compilers
are broken, or is it a defect?



Thomas




---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Mikael Kilpeläinen
Guest





PostPosted: Sat Feb 05, 2005 3:56 am    Post subject: Re: overloading: reference vs. lvalue-transformation Reply with quote



Thomas Mang wrote:

Quote:
My questions:

1) is my reading wrong and the 2 compilers are correct?
The compilers are right, in the same page (std), in the reference binding

item, there is the exactly same example and std explicitly states it is
ambiguous.

Quote:
If yes, what part did I read wrong?
Maybe it is a bit confusing but you compare the sequences

without the lvalue transformations.


Mikael

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Thomas Mang
Guest





PostPosted: Sat Feb 05, 2005 6:03 pm    Post subject: Re: overloading: reference vs. lvalue-transformation Reply with quote




"Mikael Kilpeläinen" <belz (AT) kolumbus (DOT) fi> schrieb im Newsbeitrag
news:ctnl52$e1i$1 (AT) phys-news1 (DOT) kolumbus.fi...
Quote:
Thomas Mang wrote:

My questions:

1) is my reading wrong and the 2 compilers are correct?
The compilers are right, in the same page (std), in the reference binding
item, there is the exactly same example and std explicitly states it is
ambiguous.


Oh yes, just some subbullets later....
[Still my opinion is the normative text contradicts the example.]


Quote:

If yes, what part did I read wrong?
Maybe it is a bit confusing but you compare the sequences
without the lvalue transformations.


I know that.
But the implication is the original non-identity conversion sequence will
become now an identity conversion sequence because of omitting lvalue
transformation, in order to resolve the last sentence of this subbullet to
reflect the intended behavior.
However, at the time 13.3.3.2 is entered, the formal conversion sequences
are already determined. Unless the Standard says otherwise (it doesn't in
the normative text, at least I couldn't find it) you have still
identity-conversion vs. non-identity conversion.

As Mike Miller has pointed out in private correspondance (I have contacted
EDG for clarification, since I got no response in this group), it could have
said "empty conversion sequence is subsequence of any non-empty conversion
sequence", which makes the issue different. But no, it says otherwise.

Maybe a defect, maybe not, possibly just confusing. However, using some
better words couldn't hurt at all IMHO.


Thomas


---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.