This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: g++ 2.95.2 bug


> This is a report of a g++ 2.95.2 bug. I believe the program below should
> compile and return 0 (it does with edg).

Thanks for your bug report. I believe g++ is right, which would then
indicate an error in edg.

> test.cpp:5: candidates are: int foo<const char[2]>(const char (&)[2])
> test.cpp:12:                 int foo<const char>(const char *)

You did not explain why you think g++ is incorrect, let's take it
step-by-step.

First, I assume that both functions are indeed viable candidates, with
template argument deduction deducing const char[2] and const char,
respectively. If that is questionable, please let me know.

Now, let's consider the necessary conversion sequences. For the call
too foo(const char*), an array-to-pointer conversion is needed, with
no additional conversions.

For the call to foo(const char(&)[2]), an initialization via direct
reference binding can be performed, according to 8.5.3/5 (note that
the character literal is an lvalue which is reference-compatible with
the parameter type).

According to 13.3.3.2/3, neither conversion sequence is better than
the other: both are standard conversion sequences, and neither is a
proper subsequence of the other (since Lvalue Transformations are
ignored), both sequences are of Exact Match Rank, neither involves
qualification conversion, and one of them is not a reference binding.

According to 13.3.3/2, the call is ill-formed.

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]