https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102367
Bug ID: 102367 Summary: Types may be defined in `decltype` or `sizeof` expressions in C++20 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- Since C++20 lambdas are allowed in not-evaluated context. So the code as follows must be valid: ``` using T = decltype( []{ struct S{}; return S{}; }() ); [[maybe_unused]] constexpr auto N = sizeof( []{ struct S{}; return S{}; }() ); ``` It is indeed accepted by MSVC and Clang, but rejected by GCC, demo: https://gcc.godbolt.org/z/jYjxcr1eP The error is ``` error: types may not be defined in 'decltype' expressions 1 | using T = decltype( []{ struct S{}; return S{}; }() ); | ^ <source>: In lambda function: <source>:4:33: error: types may not be defined in 'sizeof' expressions 4 | = sizeof( []{ struct S{}; return S{}; }() ); | ```