https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91420
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Waterman from comment #2) > The RISC-V code models currently in existence place a 2 GiB limit on > the extent of the statically linked portion of a binary. Rather than > a bug, I would describe this as a limitation of the existing code > models, which we should eventually lift by introducing larger code > models. > > Note that it's possible to get similar errors on other > architecture/code model combinations. Here's an example from x86-64 > with the "kernel" code model: > > $ g++ -mcmodel=kernel -O2 riscv_cpp_test.c > tmp/ccEm3wfH.o: In function `main': > test.c:(.text.startup+0x20): relocation truncated to fit: R_X86_64_32S > against `.LC0' > collect2: error: ld returned 1 exit status That is definitely a bug in mcmodel=kernel in the x86backenbd which is different from the problem here even though both have same testcase. Anyways simplified testcase: ``` const char *f() { return "1" + 2147483647; } int main() {} ```