https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112434
Bug ID: 112434 Summary: unexpected error when compiling for riscv64: invalid 'asm': invalid use of '%c' Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: rsworktech at outlook dot com Target Milestone: --- Created attachment 56528 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56528&action=edit Reduced source file When compiling the provided source file, an unexpected error happens: testcase.i: In function 'produce_asm_define': testcase.i:15:3: error: invalid 'asm': invalid use of '%c' 15 | __asm__("# FUNCTION_OFFSET_INSTANCE = %c0" | ^~~~~~~ This could be reproduced on riscv64 or x86_64(using a cross compiler) Commandline used for reproduction: On x86_64: riscv64-linux-gnu-gcc -S testcase.i On riscv64: gcc -S testcase.i It is expected that this file could be compiled without error because: 1. On x86_64, the following commandline works fine: gcc -S testcase.i 2. On x86_64, cross compilation to aarch64 works fine: aarch64-linux-gnu-gcc -S testcase.i 3. On riscv64, the same source file could be compiled by clang: clang -S testcase.i This is also reproducible with gcc 12.3.0. The reduced testcase.i is attached.