Bug 92707 - type alias on type alias on lambda in unevaluated context does not work
Summary: type alias on type alias on lambda in unevaluated context does not work
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: 14.0
Assignee: Not yet assigned to anyone
URL:
Keywords: c++-lambda, rejects-valid
: 114654 (view as bug list)
Depends on:
Blocks: c++-lambda-decltype lambdas
  Show dependency treegraph
 
Reported: 2019-11-28 12:27 UTC by Ivan Sorokin
Modified: 2024-04-13 15:13 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Sorokin 2019-11-28 12:27:50 UTC
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.
Comment 1 Frank Heckenbach 2023-05-31 15:52:32 UTC
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.
Comment 2 Patrick Palka 2024-04-09 12:20:20 UTC
*** Bug 114654 has been marked as a duplicate of this bug. ***
Comment 3 Drea Pinski 2024-04-13 07:33:34 UTC
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.
Comment 4 Patrick Palka 2024-04-13 15:13:06 UTC Comment hidden (obsolete)