GCC shows an error on this code: template <typename T> using foo = decltype([] {}); template <typename U> using bar = foo<U>; extern foo<int> a; extern bar<int> a; // error: 'bar' does not name a type The error is wrong because bar is a regular type alias. Clearly it names a type. If I replace the lambda with an integer the error goes away.
Probably the same bug in a slightly different form: % cat test.cpp template <typename> struct S { }; template <int> using A = S <decltype ([] { })>; template <int d> using B = A <d>; B <0> a; % g++ -std=c++20 -Wall -Wextra test.cpp test.cpp:4:1: error: 'B' does not name a type 4 | B <0> a; | ^ It works when using A instead of B. It works when using an alias for "decltype ([] { })". Other compilers accept it as is. Also, I find the message confusing (even if it was rightly rejected): Of course, 'B' does not name a type. It's followed by template arguments, so 'B' shouldn't be a type, but a template or template alias, or 'B <0>' should be a type.
*** Bug 114654 has been marked as a duplicate of this bug. ***
Note clang rejects the original testcase in comment #0 but EDG, MSVC all accept it. Plus GCC now accepts it on the trunk. So closing as fixed.
*** Bug 106221 has been marked as a duplicate of this bug. ***