[cfe-commits] r166455 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/SemaCXX/libstdcxx_common_type_hack.cpp www/cxx_status.html

Richard Smith richard at metafoo.co.uk
Mon Oct 22 18:19:35 PDT 2012

On Mon, Oct 22, 2012 at 5:40 PM, Chandler Carruth <chandlerc at google.com> wrote:
> On Mon, Oct 22, 2012 at 5:32 PM, Richard Smith
> <richard-llvm at metafoo.co.uk> wrote:
>> Author: rsmith
>> Date: Mon Oct 22 19:32:41 2012
>> New Revision: 166455
>> URL: http://llvm.org/viewvc/llvm-project?rev=166455&view=rev
>> Log:
>> Ugly ugly hack for libstdc++-4.6 and libstdc++-4.7 compatibility. These
>> libraries have an incorrect definition of std::common_type (inherited from a
>> bug in the standard -- see LWG issue 2141), whereby they produce reference
>> types when they should not.
>> If we instantiate a typedef named std::common_type<...>::type, which is defined
>> in a system header as decltype(... ? ... : ...), and the decltype produces a
>> reference type, convert it to the non-reference type. (This doesn't affect any
>> LWG2141-conforming implementation of common_type, such as libc++'s, because the
>> default implementation of common_type<...>::type isn't supposed to produce a
>> reference type.)
>> This is horrible. I'm really sorry. :( Better ideas appreciated!
> So, we discussed potentially using a version test macro for this, and
> I think I might like that.
> I understand that this will cause a failure with other system
> libraries, but I actively want that -- they should get a bug report
> about their broken behavior before we include them in the hack to
> carry on bravely forward.
> Essentially, I want to only do this for standard libraries which have
> *shipped* with this bug and thus cannot be fixed in their source. That
> gives us a much better chance of deleting this code when those
> libraries are long gone.

Yeah, I'd be happy to tie this to the existence of a __GLIBCXX__
macro, but not to its definition: I don't want to revisit this if
another broken point release of libstdc++ happens, and libstdc++ will
eventually be kept in line by g++ implementing the rules correctly.
Would that work for you?

More information about the cfe-commits mailing list