On Sun, Aug 28, 2011 at 2:32 PM, Milian Wolff <m...@milianw.de> wrote: > On Saturday 27 August 2011 23:44:02 Jeffrey Walton wrote: >> I want to use double checked initialization for a program, but I'm >> catching some warnings from helgrind. A typical use is shown below. >> >> Its kind of tedious to run --gen-suppressions=yes for to develop >> suppressions. Plus, the suppression rules are only applicable to the >> current name mangling scheme. >> >> Is there a helgrind friendly way to write the initialization so that I >> don't get a warning? > > Reading http://en.wikipedia.org/wiki/Double-checked_locking I'd think that the > warnings are valid - no? Only MSVC apparently interpretes volatile in a way > that would make this a safe pattern in C++.
It depends. If a memory barrier is present between initialization of the allocated structure and assignment to the variable "init", the code posted by Jeffrey should be safe even without "init" having been declared volatile. Bart. ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users