An error of gcc-ss-20030303
Jie Zhang
zhangjie@magima.com.cn
Wed Apr 23 10:36:00 GMT 2003
The following code is copied from spinlock.c in uClibc (after
preprocessing and 'inline' after static removed):
static void __pthread_release(int * spinlock)
{
asm ("" : : : "memory");
*spinlock = 0;
__asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
}
When compiled using gcc-3.0.2, no error is reported. But gcc-3.2 and
gcc-ss-20030303 report the follwing error:
t.c: In function `__pthread_release':
t.c:5: inconsistent operand constraints in an `asm'
I dump the rtl using -dr and find that gcc-3.0.2 uses a pseudo register
to hold the address of 'spinlock' and the output operand and input
operand of __asm__ use the same register. But gcc-ss-20030303 uses two
pseudo registers for the output operand and input operand of __asm__
respectively, both pseudo registers hold the same value -- the address
of 'spinlock'. Then when checking the constraints, gcc reports the error.
Is it a bug of gcc-3.2.x and gcc-3.3? Or the above __asm__ usage is
wrong in gcc-3.2.x and gcc-3.3? I think gcc-3.0.2 is right?
- Jie
More information about the Gcc
mailing list