https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108361
Bug ID: 108361 Summary: Assembly code that is never called emitted on x86_64 Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eric-bugs at omnifarious dot org Target Milestone: --- Created attachment 54236 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54236&action=edit Preprocessed C++ code that generates unneeded assembly The nature of this bug makes a concise test case hard to whittle down to something minimal... The attached code generates a whole bunch of assembly that isn't needed. This assembly references external symbols as well, which creates unnecessary linker errors. Clang handles it just fine. :-) Attached is both the preprocessed C++ code, and the assembly it generates. The only needed assembly is the code for main and the static data main needs. _start is defined as a global in a separate file, which is also attached. The compile command I'm using: g++ -std=c++20 -march=znver2 -static -O3 -nostartfiles -nostdlib -I/usr/include/c++/12 -I/home/hopper/src/posixpp/pubincludes -Wl,-e_start preprocessed.s x86_64_start.s