This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with inline assembler in gcc-3.2


> 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?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]