Problems with inline assembler in gcc-3.2

Richard Earnshaw rearnsha@arm.com
Thu Oct 31 04:07:00 GMT 2002


> On Fri, Oct 25, 2002 at 02:40:54PM +0530, Jaimon Jose wrote:
> > static inline int atomic_inc(volatile int *p)
> > {
> > 	__asm__ __volatile__(
> > 		"lock; incl %0"
> > 		:"=m" (*p)
> > 		:"0" (*p));
> 
> You're in dicey territory here.  The compiler believes that
> you have two references to a volatile memory, and so it can't
> put them at the same location.  This is clearly not what you
> intended.
> 
> File a bug.  This should be handled more gracefully.
> 

Does using

	__asm__ __volatile__(
		"lock; incl %0"
		:"+m" (*p));

work?




More information about the Gcc-bugs mailing list