Topic: Example in 13.3.3.2/3: does it illustrate what it is intended supposed to illustrate?


Author: Andrey Tarasevich <andreytarasevich@hotmail.com>
Date: Wed, 27 Oct 2010 12:05:07 CST
Raw View
Hello

(I have a feeling that I've seen this asked before, but anyway...)

I'm looking at 13.3.3.2/3 that deals with comparison of conversion sequence=
s
of the same form. With regard to standard conversion sequences it states
that

 =97 Standard conversion sequence S1 is a better conversion sequence than
standard conversion sequence S2 if
   =97 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)
   =97 the rank of S1 is better than the rank of S2, or S1 and S2 have the
same rank and are distinguishable by the rules in the paragraph below, or,
if not that,
   =97 S1 and S2 differ only in their qualification conversion and yield
similar types T1 and T2 (4.4), respectively, and the cv-qualification
signature of type T1 is a proper subset of the cv-qualification signature o=
f
type T2, and S1 is not the deprecated string literal array-to-pointer
conversion (4.2).

The third rule is followed by an example

 int f(const int *);
 int f(int *);
 int i;
 int j = f(&i); // Calls f(int *)

>From the way the example is placed in the text it appears that this example
is intended to serve as an illustration for the third rule exclusively, i.e=
since the cv-qualification of `int *` is a subset of cq-qualifications of
`const int *`, the `foo(int *)` wins the resolution.

However, since there's no such thing as an "identity qualification
conversion", to me it looks like this example actually illustrates the firs=
t
rule (as quoted above), not the third one. A call to `foo(int *)` requires
no conversion at all (i.e. an identity conversion), while a call to
`foo(const int *)` requires a qualification conversion. Since identity
conversion is a subset of any non-identity conversion sequence, `foo(int *)=
`
wins the overload resolution. I.e. this situation is already covered by the
first rule. There's no need to bring in the third one.

Correct me if I'm wrong, but in order to illustrate the effects of the thir=
d
rule one would need an example that looks as follows

 int f(const volatile int *);
 int f(const int *);
 int i;
 int j = f(&i); // Calls f(const int *)

So, what was the intent behind the example used in the standard? Maybe it
was intended to illustrate the effect of all three rules (presented before
the example)? If that's the case, then the placement of that example in the
text is confusing, to say the least. If it was intended to illustrate the
third rule alone, then it appears to be plain incorrect. Am I missing
something simple here?

--
Best regards,
Andrey Tarasevich

[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use
mailto:std-c++@netlab.cs.rpi.edu<std-c%2B%2B@netlab.cs.rpi.edu>
]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]