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]

[Bug c/40693] New: atomic built-ins malfunction with 64-bit and optimization


#include <stdint.h>
#include <stdio.h>

int
main(int ac, char *av[])
{
    int64_t x;
    int64_t like_a_constant = -1;
    int64_t unlike_a_constant = -1;

    if (ac == 0) unlike_a_constant = 5;

    x = 0;
    __sync_add_and_fetch(&x, like_a_constant);
    printf("%016llx\n", x);

    x = 0;
    __sync_add_and_fetch(&x, unlike_a_constant);
    printf("%016llx\n", x);
}

Expected result:
ffffffffffffffff
ffffffffffffffff

Actual result:
00000000ffffffff
ffffffffffffffff


-- 
           Summary: atomic built-ins malfunction with 64-bit and
                    optimization
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: m dot rosellini at f5 dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40693


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