I have some code (will be attached) that fails to compile with GCC 4.5.0 if you
use the exact right (wrong) flags:

$ g++-4.5.0 -fPIC -m32 -O2 -c cpuid.cpp -o cpuid.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h: In function 'unsigned
int get_x86_cache_line_size()':
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: can't
find a register in class 'CLOBBERED_REGS' while reloading 'asm'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm'
operand has impossible constraints
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm'
operand has impossible constraints
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/cpuid.h:179:52: error: 'asm'
operand has impossible constraints

If not using -fPIC, or if using -O instead of -O2, it compiles. This code
compiles with the same flags (and any other permutation I've thought to try)
with GCC 4.3.1 and 4.4.3. As far as I know the code is valid. I've pruned it
down as much as I could.

$ g++-4.5.0 -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /tmp/portage/sys-devel/gcc-4.5.0/work/gcc-4.5.0/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.0/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-lto --enable-nls
--without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --enable-multilib --enable-libmudflap
--disable-libssp --enable-libgomp --enable-cld
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.0/python
--disable-libgcj --enable-languages=c,c++,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.0 p1.0'
Thread model: posix
gcc version 4.5.0 (Gentoo 4.5.0 p1.0) 

This is the Gentoo build of GCC 4.5.0, but I've checked the packaging; there
are no noticeable patches being applied to the 4.5.0 sources, so I think this
is a problem in vanilla 4.5.0.


-- 
           Summary: Using cpuid.h, can't find a register in class
                    'CLOBBERED_REGS' while reloading 'asm'
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lloyd at randombit dot net
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44018

Reply via email to