This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/51811] New: [C++0x] Incorrect incrementation/decrementation of atomic pointers
- From: "t.schuele at web dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Jan 2012 14:22:33 +0000
- Subject: [Bug libstdc++/51811] New: [C++0x] Incorrect incrementation/decrementation of atomic pointers
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51811
Bug #: 51811
Summary: [C++0x] Incorrect incrementation/decrementation of
atomic pointers
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: t.schuele@web.de
Incrementation (decrementation) of atomic pointers does not work correctly. On
an x86-64 machine the piece of code given below produces the following output
(or something similar):
0x7fffbe6d082c
0x7fffbe6d082d
0x7fffbe6d0830
0x7fffbe6d082d
There are two problems here: Firstly, the pointer is incremented by 1 and not
by sizeof(int). Secondly, the last two lines of the output should be the same.
Note that the second problem seems to be fixed in gcc-4.7-20120107, while the
first one still occurs. Thanks for your help!
----------------------------
#include <iostream>
#include <atomic>
using namespace std;
int main(int argc, char* argv[]) {
int value = 42;
atomic<int*> my_pointer;
my_pointer = &value;
cout << my_pointer++ << endl;
cout << my_pointer << endl;
my_pointer = &value;
cout << ++my_pointer << endl;
cout << my_pointer << endl;
}