The following code gives a hard error. I believe it should not. template<typename T> T && declval(); template<typename T> struct void_ { using type = void; }; template<typename T> using void_t = typename void_<T>::type; template<class A, class B> struct Outer { template<class C, class D> using Inner = decltype(true ? declval<C>() : declval<D>()); }; template<class A, class B, typename Enable = void> struct S {}; template<class A, class B> struct S<A, B, void_t<typename Outer<A, B>::template Inner<A, B>>> {}; struct A{}; struct B{}; int main() { S<A, B> s; } The error: test.cpp: In substitution of ‘template<class A, class B> template<class C, class D> using Inner = decltype ((true ? declval<C>() : declval<D>())) [with C = A; D = B; A = A; B = B]’: test.cpp:32:13: required from here test.cpp:15:33: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘A’, and ‘B’) using Inner = decltype(true ? declval<C>() : declval<D>()); ^
Clang accepts the code without a hard error.
Mine.
Author: paolo Date: Fri Feb 13 14:54:48 2015 New Revision: 220684 URL: https://gcc.gnu.org/viewcvs?rev=220684&root=gcc&view=rev Log: /cp 2015-02-13 Paolo Carlini <paolo.carlini@oracle.com> PR c++/64970 * decl.c (make_typename_type): Pass tsubst_flags_t argument to lookup_template_class. /testsuite 2015-02-13 Paolo Carlini <paolo.carlini@oracle.com> PR c++/64970 * g++.dg/cpp0x/sfinae55.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/sfinae55.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed for 5.0.