-fPIC bug

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Fri Jun 9 02:19:00 GMT 2000


> unless I'm on crack, this looks like a bug where
> the compiler allows a register to be clobbered without
> doing anything about it.
> 
> % cat foo.c
> int foo(){
>     asm("mov $0,%%ebx":::"%ebx");
>     return 0;
> }

You are using the constraint incorrectly; %ebx means something
different. One way to write what you want is

int foo(){
    int dummy;
    asm("mov $0,%%ebx":"=b"(dummy));
    return 0;
}

in which case you'll get

Invalid `asm' statement:
fixed or forbidden register 3 (bx) was spilled for class BREG.

IOW, with -fPIC, you must not use ebx (just in case you didn't know).

regards,
Martin



More information about the Gcc-bugs mailing list