[cfe-dev] [clang-3.2] unique_ptr: compiler errors
Suman Kar
skarpio at gmail.com
Mon Jun 4 18:47:17 PDT 2012
On Tue, Jun 5, 2012 at 5:49 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> Hi,
>
> On Sat, Jun 2, 2012 at 10:45 AM, Suman Kar wrote:
[...]
>>
>> I'd like to know if this is a problem with my installation/gcc/build
>> issue. Any help will be much appreciated.
>
> This is a libstdc++ bug, in code which seems to be Win32-specific. The
> code looks like this (around ext/concurrence.h:273):
>
> template<typename _Rm>
> static typename __enable_if<sizeof(&_Rm::sema), void>::__type
> _S_destroy(_Rm* __mx)
>
> The intent appears to be to cause a substitution failure if there is
> no _Rm::sema member, but the actual effect is that this is always
> ill-formed in C++11 mode, since a pointer/pointer-to-member has size >
> 1, and thus the sizeof expression can't be narrowed to bool. You can
> fix this header by casting the result of sizeof to bool:
>
> static typename __enable_if<(bool)sizeof(&_Rm::sema), void>::__type
>
> I've filed this against libstdc++ as gcc.gnu.org/PR53578.
This is great! Thanks a ton!
I've just patched the header. However, it is rather strange that the
same code compiles as-is (i.e. without patching) with gcc 4.6.2
(-std=c++0x -Wall) but complains with clang (-std=c++11 -Wall). I
take it to be a limitation on gcc's part, of C++11 support,
specifically the bit about narrowing.
There are some helpful comments (already!) on the gcc bug too.
Regards,
Suman
More information about the cfe-dev
mailing list