This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/40693] New: atomic built-ins malfunction with 64-bit and optimization
- From: "m dot rosellini at f5 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2009 23:10:45 -0000
- Subject: [Bug c/40693] New: atomic built-ins malfunction with 64-bit and optimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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