http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53000

             Bug #: 53000
           Summary: Trinary operator does not behave as standardized
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: gcc-b...@quasiparticle.net


The conditional operator as implemented in g++ from 4.7.0 (at least) onwards
does not behave as required by [expr.cond]p3 of the C++11 spec.

Given an expression "B ? E1 : E2", the result of the expression is required to
be an xvalue if E2 is an xvalue and E1 can be converted to T2&&. With E1 and E2
both being declval<int>(), the result should then be of type int&&, while g++
currently generates a plain int there.

Curiosly, this hides an oversight described in DR2141 [1], which reports the
common_type<T, U> trait as being defective. As soon as "true ? declval<int>() :
declval<int>()" yields int&& as required, common_type<int, int>::type of
libstdc++ will be int&& (is int right now). This will break <chrono> badly, as
experienced by clang++.


[1] http://cplusplus.github.com/LWG/lwg-active.html#2141

Reply via email to