public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/54906] New: write introduction incorrect wrt the C++11 memory model (case with atomic accesses)
@ 2012-10-12 7:22 francesco.zappa.nardelli at gmail dot com
2012-10-12 7:46 ` [Bug tree-optimization/54906] " jakub at gcc dot gnu.org
2012-10-18 23:44 ` aldyh at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: francesco.zappa.nardelli at gmail dot com @ 2012-10-12 7:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54906
Bug #: 54906
Summary: write introduction incorrect wrt the C++11 memory
model (case with atomic accesses)
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: francesco.zappa.nardelli@gmail.com
The program below is miscompiled by g++ --param allow-store-data-races=0 -O2
(or -O3).
$ g++ -v
gcc version 4.8.0 20121011 (experimental) (GCC)
#include <atomic>
using namespace std;
uint8_t g_5;
atomic_ushort a_9;
atomic_schar a_24;
void func_1 () {
if (a_9.load ())
for (g_5 = 0; 0; g_5++) {
}
a_24.store (0);
}
int main () {
func_1 ();
return 0;
}
The assembly code generated by -O3 for func_1 is:
_Z6func_1v:
movzwl a_9(%rip), %edx
xorl %eax, %eax
testw %dx, %dx
movzbl g_5(%rip), %edx
cmove %edx, %eax
movb %al, g_5(%rip)
movb $0, a_24(%rip)
mfence
ret
This code loads and restores the global variable g_5, while the reference
semantics for the source program does not perform a write to g_5. It is easy
to write a non-racy context that observes this unexpected behaviour.
[Bug 54900 might be related or not; in the example here the write is introduced
only if a_24 is an atomic variable].
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/54906] write introduction incorrect wrt the C++11 memory model (case with atomic accesses)
2012-10-12 7:22 [Bug tree-optimization/54906] New: write introduction incorrect wrt the C++11 memory model (case with atomic accesses) francesco.zappa.nardelli at gmail dot com
@ 2012-10-12 7:46 ` jakub at gcc dot gnu.org
2012-10-18 23:44 ` aldyh at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-10-12 7:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54906
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-10-12
CC| |jakub at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-10-12 07:46:25 UTC ---
Yeah, looks like dup of PR54900 to me, the unconditional write is again
introduced by ce1 pass.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/54906] write introduction incorrect wrt the C++11 memory model (case with atomic accesses)
2012-10-12 7:22 [Bug tree-optimization/54906] New: write introduction incorrect wrt the C++11 memory model (case with atomic accesses) francesco.zappa.nardelli at gmail dot com
2012-10-12 7:46 ` [Bug tree-optimization/54906] " jakub at gcc dot gnu.org
@ 2012-10-18 23:44 ` aldyh at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-10-18 23:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54906
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |aldyh at gcc dot gnu.org
Resolution| |FIXED
--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-10-18 23:44:01 UTC ---
resolved with patch to 54900.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-10-18 23:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-12 7:22 [Bug tree-optimization/54906] New: write introduction incorrect wrt the C++11 memory model (case with atomic accesses) francesco.zappa.nardelli at gmail dot com
2012-10-12 7:46 ` [Bug tree-optimization/54906] " jakub at gcc dot gnu.org
2012-10-18 23:44 ` aldyh at gcc dot gnu.org
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).