I'm seeing something strange while implementing C++0x declval. In a nutshell, since I'm not reading anything in 5.16 (of C++03) saying that the type of a conditional expression depends on the value of its first expression, I'm surprised that this is the case with GCC, as far as cv-qualification is concerned.
By the way, if actually this is conforming behavior, then the current C++0x specifications for the two arguments common_type become really weird (see 20.6.7/3 in N2960): the cv-qualification of the common_type ends up depending on the order of the types. Cannot be right, IMHO. For example, the below doesn't compile: template<typename _Tp> struct __declval_protector { static _Tp __delegate(); }; template<typename _Tp> _Tp declval() { return __declval_protector<_Tp>::__delegate(); } template<typename _Tp, typename _Up> struct common_type { typedef __decltype(true ? declval<_Tp>() : declval<_Up>()) typet; typedef __decltype(false ? declval<_Tp>() : declval<_Up>()) typef; }; template<typename, typename> struct is_same; template<typename _Tp> struct is_same<_Tp, _Tp> { typedef _Tp type; }; void f() { typedef common_type<int, const int>::typet typet; typedef common_type<int, const int>::typef typef; typedef is_same<typet, typef>::type type; } -- Summary: cv-qualification of conditional expression type depending on the value of its first expression?!? Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: paolo dot carlini at oracle dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42013