in this simple function bug.c: void restore() { register long reg_ebx asm ("ebx"); reg_ebx = saved_ebx; }
$ gcc -v Utilisation des specs internes. Target: i386-redhat-linux Configuré avec: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=i386-redhat-linux Modèle de thread: posix gcc version 4.3.2 20080905 (Red Hat 4.3.2-3) (GCC) $ uname -a Linux lima.univ-paris1.fr 2.6.24-0.83.rc5.fc9 #1 SMP Tue Dec 11 12:04:08 EST 2007 i686 i686 i386 GNU/Linux $ gcc -O -S -ffixed-ebx -fomit-frame-pointer bug.c $ cat bug.c restore: rep ret .size restore, .-restore .comm saved_ebx,4,4 the function is empty: the assignment to reg_ebx has been discarded (because considered as a local variable). In the presence of asm it should be kept. It is OK if -O is not given. Maybe there is a way do it differently (btw I cannot declare the var as global nor static in my application). -- Summary: probelm with optmization and local variable stored in an asm register Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: daniel dot diaz at univ-paris1 dot fr GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37613