https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101727
Bug ID: 101727 Summary: invalid symbol redefinition when -O2 enabled Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: zhan3299 at purdue dot edu Target Milestone: --- Following code can be successfully compiled with O0 optimization enabled, but not O2. Example code: --- #include <stdio.h> int func() { int filter; asm volatile( " leaq _filter(%%rip), %%rax\n" " jmp _out\n" "_filter:\n" ".ascii \"\\040\"\n" "_out:" : "=rax"(filter) : :); return filter; } int main() { printf("%#x", func()); return 0; } --- Error messages of O2: --- ASM generation compiler returned: 0 <source>: Assembler messages: <source>:7: Error: symbol `_filter' is already defined <source>:9: Error: symbol `_out' is already defined Execution build compiler returned: 1 --- It affects 11.0, 12.0. O2: https://godbolt.org/z/j9xG96fxW O0: https://godbolt.org/z/b4TqddvYh