http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793
Bug #: 51793 Summary: pragma GCC optimize wrapv leads to invalid code on Solaris Classification: Unclassified Product: gcc Version: 4.5.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: br...@clisp.org Created attachment 26274 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26274 Test case The use of #pragma GCC optimize ("wrapv") with optimization level -O2 turns the ".p2align 4,,15" to ".p2align 4,,-1". This can be observed on both i386-pc-solaris2.11 and i386-pc-linux-gnu systems. On i386-pc-solaris2.11 it causes a compilation failure, because the assembler does not understand this syntax. How to reproduce: ================================== foo.c ================================== #pragma GCC optimize ("wrapv") int foo () { return 17; } int bar () { return 42; } =========================================================================== $ gcc -O2 -c foo.c Assembler: foo.c "/var/tmp//ccwQaWQO.s", line 3 : .align test amount has negative value "/var/tmp//ccwQaWQO.s", line 10 : .align test amount has negative value $ gcc -O2 -S foo.c $ cat foo.s .file "foo.c" .text .p2align 4,,-1 .globl foo .type foo, @function foo: movl $17, %eax ret .size foo, .-foo .p2align 4,,-1 .globl bar .type bar, @function bar: movl $42, %eax ret .size bar, .-bar .ident "GCC: (GNU) 4.5.2" $ gcc --version gcc (GCC) 4.5.2 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/gcc/4.5/lib/gcc/i386-pc-solaris2.11/4.5.2/lto-wrapper Target: i386-pc-solaris2.11 Configured with: /builds/hudson/workspace/nightly/build/i386/components/gcc45/gcc-4.5.2/configure CC=/ws/onnv-tools/SUNWspro/sunstudio12.1/bin/cc CXX=/ws/onnv-tools/SUNWspro/sunstudio12.1/bin/CC --prefix=/usr/gcc/4.5 --mandir=/usr/gcc/4.5/share/man --bindir=/usr/gcc/4.5/bin --libdir=/usr/gcc/4.5/lib --sbindir=/usr/gcc/4.5/sbin --enable-languages=c,c++,fortran,objc --enable-shared --with-gmp-include=/usr/include/gmp --with-mpfr-include=/usr/include/mpfr --prefix=/usr/gcc/4.5 --mandir=/usr/gcc/4.5/share/man --infodir=/usr/gcc/4.5/share/info --libexecdir=/usr/gcc/4.5/lib CFLAGS='-g -O2 ' Thread model: posix gcc version 4.5.2 (GCC) $ type as as is hashed (/usr/bin/as) $ as -V as: Sun Compiler Common 12 SunOS_i386 snv_174 08/25/2011 Usage: as [-V] [-Q{y,n}] [-s] [-S[aAbBcClL]] [-K {pic,PIC}] [-o objfile] [-L] [-T] [-P [[-Ipath] [-Dname] [-Dname=def] [-Uname]]...] [-m [-Ym,path]] [-n] [-xF] [-F] [-b] [-i] file.s ...