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{}; }() ); | ```
I thought there was a dup of this bug somewhere. Anyways confirmed.
(In reply to Andrew Pinski from comment #1) > I thought there was a dup of this bug somewhere. > Anyways confirmed. I did, PR 101911. *** This bug has been marked as a duplicate of bug 101911 ***