https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86027
Bug ID: 86027 Summary: string literals get corrupted with -O3 and gas on solaris i386 Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: subscribe at teskor dot de Target Milestone: --- Created attachment 44224 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44224&action=edit source reproducing the error GCC is Configured with: ../configure --with-cpu-32=i386 --prefix=/opt/gcc-7.3.0 --with-gnu-as --with-as=/opt/csw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-gmp=/opt/csw --with-mpfr=/opt/csw --with-mpc=/opt/csw ABI=32 Target is: i386-pc-solaris2.10 In this configuration, the output of the test program is corrupted. What should be 12\n3 becomes some random 3 bytes (depending heavily on the code layout, they changed everytime I deleted some unneeded functions from the code). If using -O0, the problems goes away. Only strings literals which are used more than once in the code get garbled. (the "\n" and and "12", while the "3" stays correct). Reconfiguring the compiler to use the native assembler in /usr/ccs/bin/as fixed the problem, but unfortunately there the -pipe option ceases to work (but that's a different issue). It seems to, that when configured with --with-gnu-as on solaris, the attributes of the section containing the strings are wrongly generated in the assembler code, but that's just a guess.