Package: gcc-4.7
Version: 4.7.2-5
Severity: normal

--- Please enter the report below this line. ---

When I compile and run the small program below using
    gcc -O2 -o test test.c
    ./test
I get the (correct) output
    1

When I compile and run the small program below using
    gcc -DFAIL -O2 -o test test.c
    ./test
I get the (wrong) output
    2

The define "-DFAIL" only adds an empty asm statement which shouldn't make any 
difference (see below).

***************************************************************
#include <stdio.h>

unsigned long reg;

register unsigned long *env asm ("rbp");
register unsigned long T0 asm ("rbx");
register unsigned long T1 asm ("r12");

void
cmpxchgl(void)
{
        unsigned long dst;

        dst = *env - T0;
        if ((unsigned) dst == 0) {
                T0 = (T0 & ~0xffffffff) | (T1 & 0xffffffff);
        } else {
                *env = (*env & ~0xffffffff) | (T0 & 0xffffffff);
        }
#ifdef FAIL
        asm volatile ("");
#endif
}

int
main(void)
{
        env = &reg;

        *env = 0;
        T0 = 1;
        T1 = 2;
        cmpxchgl();
        printf("%lx\n", T0);

        return 0;
}
***************************************************************

--- System information. ---
Architecture: amd64
Kernel:       Linux 3.2.0-4-amd64

Debian Release: 7.1
  500 stable-updates  ftp.de.debian.org 
  500 stable          security.debian.org 
  500 stable          ftp.de.debian.org 

--- Package information. ---
Depends               (Version) | Installed
===============================-+-===============
gcc-4.7-base        (= 4.7.2-5) | 4.7.2-5
cpp-4.7             (= 4.7.2-5) | 4.7.2-5
binutils            (>= 2.21.1) | 2.22-8
libgcc1          (>= 1:4.7.2-5) | 1:4.7.2-5
libgomp1           (>= 4.7.2-5) | 4.7.2-5
libitm1            (>= 4.7.2-5) | 4.7.2-5
libquadmath0       (>= 4.7.2-5) | 4.7.2-5
libc6                 (>= 2.11) | 2.13-38
libgmp10                        | 2:5.0.5+dfsg-2
libmpc2                         | 0.9-4
libmpfr4             (>= 3.1.0) | 3.1.0-5
zlib1g             (>= 1:1.1.4) | 1:1.2.7.dfsg-13


Recommends       (Version) | Installed
==========================-+-============
libc6-dev      (>= 2.13-5) | 2.13-38


Suggests                     (Version) | Installed
======================================-+-===============
gcc-4.7-multilib                       | 4.7.2-5
libmudflap0-4.7-dev       (>= 4.7.2-5) | 
gcc-4.7-doc                 (>= 4.7.2) | 4.7.2-2
gcc-4.7-locales             (>= 4.7.2) | 
libgcc1-dbg                            | 
libgomp1-dbg                           | 
libitm1-dbg                            | 
libquadmath0-dbg                       | 
libmudflap0-dbg                        | 
libcloog-ppl0           (>= 0.15.9-2~) | 
libppl-c2                              | 
libppl7                                | 
binutils-gold              (>= 2.21.1) | 


-- 
To UNSUBSCRIBE, email to debian-gcc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/201307031144.17002.

Reply via email to