This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: -fPIC bug
- To: davek at ca dot mgisoft dot com
- Subject: Re: -fPIC bug
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 9 Jun 2000 11:12:26 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <3940AAB6.46749C5C@ca.mgisoft.com>
> 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