https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119764
Bug ID: 119764 Summary: noexcept lambdas do not have unused captures get pruned Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nshead at gcc dot gnu.org Target Milestone: --- The following sample fails because the non-ODR usage of 'x' does not get pruned in 'b': int main() { const int x = 123; auto a = [&]() { return x; }; auto b = [&]() noexcept { return x; }; static_assert(sizeof(a) == sizeof(b)); } 'g++ main.cpp' gives: main.cpp: In function 'int main()': main.cpp:5:29: error: static assertion failed 5 | static_assert(sizeof(a) == sizeof(b)); | ~~~~~~~~~~^~~~~~~~~~~~ main.cpp:5:29: note: the comparison reduces to '(1 == 8)' This gave a segmentation fault instead until r9-2784-g86e95f35c52213 (PR87185).