This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/46096] Code produces two different outputs when optimized respectively with -O2 and without it.
- From: "zweifel at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Oct 2010 14:45:33 +0000
- Subject: [Bug c++/46096] Code produces two different outputs when optimized respectively with -O2 and without it.
- Auto-submitted: auto-generated
- References: <bug-46096-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46096
Danilo <zweifel at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #10 from Danilo <zweifel at gmail dot com> 2010-10-20 14:45:18 UTC ---
(In reply to comment #8)
> I don't recommend people use volatile to avoid multithreading races, it only
> prevents compiler optimisations, not hardware reordering. Using proper atomics,
> memory barriers or other explicit synchronisation is better.
> But for this testcase, yes, volatile will "fix" it.
>
> Danilo, you might like to read these
> http://www.drdobbs.com/cpp/201804238
> http://www.drdobbs.com/high-performance-computing/212701484
Thanks you very much, Jonathan! I will surely read the references.
I am considering this as closed.