https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105901
Bug ID: 105901 Summary: [C++20] Code generation bug. Well-formed Program segfaults. Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: benni at stuerz dot xyz Target Milestone: --- Created attachment 53105 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53105&action=edit The full source code. GCC versions at least 10.1 to 12.1 (and trunk on godbolt.org) are affected. System Type: Linux (x86_64) Build with: g++ -std=c++20 -Wall -Wextra The optimization level doesn't matter. And the compiler produces no warnings. Substituting g++ with clang++ makes it work. The attached file is a small project of mine to create a type-eraser for "Printable things". The expected output of the program: [[10, 20, 30], Hello World, [A random struct (1), A random struct (2), A random struct (3)]]