public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/11935] New: code using __asm__ shows incorrect behavior when compiled with -O1 flags
@ 2003-08-15 21:09 rajesh dot rajamani at siebel dot com
2003-08-15 21:28 ` [Bug inline-asm/11935] " schwab at suse dot de
0 siblings, 1 reply; 2+ messages in thread
From: rajesh dot rajamani at siebel dot com @ 2003-08-15 21:09 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11935
Summary: code using __asm__ shows incorrect behavior when
compiled with -O1 flags
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rajesh dot rajamani at siebel dot com
CC: gcc-bugs at gcc dot gnu dot org
g++ -o inc inc.cpp
./inc
j is 10
j is 11, k is 11
g++ -O1 -o inc inc.cpp
j is 10
j is 11, k is 8
----------inc.cpp------------
#include <iostream>
#include <stdio.h>
/** Atomic increment/decrement implementation
** using __asm__ interface by Rajesh Rajamani
**/
unsigned long atomic_inc(unsigned long* t) {
unsigned long rval;
__asm__ __volatile__ ("
movl $0x1,%0
lock;
xadd %0,(%1)
incl %0
"
:"=d"(rval)
:"c"(t)
);
}
int main (void) {
unsigned long int k;
static unsigned long j = 10;
printf("j is %d\n",j);
k = atomic_inc(&j);
printf("j is %d, k is %d \n",j,k);
return 0;
}
----------inc.cpp------------
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug inline-asm/11935] code using __asm__ shows incorrect behavior when compiled with -O1 flags
2003-08-15 21:09 [Bug inline-asm/11935] New: code using __asm__ shows incorrect behavior when compiled with -O1 flags rajesh dot rajamani at siebel dot com
@ 2003-08-15 21:28 ` schwab at suse dot de
0 siblings, 0 replies; 2+ messages in thread
From: schwab at suse dot de @ 2003-08-15 21:28 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11935
schwab at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
------- Additional Comments From schwab at suse dot de 2003-08-15 21:28 -------
Use -Wall.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-15 21:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 21:09 [Bug inline-asm/11935] New: code using __asm__ shows incorrect behavior when compiled with -O1 flags rajesh dot rajamani at siebel dot com
2003-08-15 21:28 ` [Bug inline-asm/11935] " schwab at suse dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).