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).
reg_ebx is obviously unused in your function so the assignment is DCEd. I guess what you try to do is not really possible with C.
Richard Guenther says it is impossible in C... In C maybe but not in GNU C :-) This worked perfectly under older versions (may gcc 3.x.x) and it is a pitty if this feature is lost now.