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++/46096] Code produces two different outputs when optimized respectively with -O2 and without it.


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.


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