[cfe-dev] Apparently valid C++ code rejected as ambiguous

Douglas Gregor dgregor at apple.com
Mon Nov 15 07:51:31 PST 2010


On Nov 13, 2010, at 8:54 AM, Csaba Raduly wrote:

> On Fri, Nov 12, 2010 at 12:33 PM, Douglas Gregor wrote:
>> 
>> On Nov 12, 2010, at 11:26 AM, Csaba Raduly wrote:
>> 
>>> Hi all,
>>> clang 2.8 fails to compile the following code:
>>> 
> (snip)
>> 
>> This *might* be related to
>> 
>>        http://llvm.org/bugs/show_bug.cgi?id=8130
> 
> Looks similar indeed. But the bug is marked fixed; my example code is
> still not accepted by: clang version 2.9 (trunk 119002)

It's fixed in Clang r119145, but you should consider a different approach, because this code will only work in C++98/03. If you turn on C++0x mode, it will become ambiguous again.

Essentially, the C++ standard didn't say (until recently!) what happened when performing function template partial ordering between a non-static member function and a free function. That got clarified for C++0x about three months ago:

	http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#532

However, the agreed-upon semantics are different than what GCC implements; hence, implementing that DR532 (which was recorded as Clang bug PR8130), left your code broken.

I've gone ahead and made Clang implement GCC's semantics in C++98/03 mode, but the correct C++0x semantics in C++0x mode.

	- Doug



More information about the cfe-dev mailing list