On Wed, Aug 12, 2015 at 6:02 PM, David Chapman <dcchap...@acm.org> wrote: > On 8/12/2015 1:09 PM, Dan Kegel wrote: >> ... > > So even though I just told you how to guarantee that global variables in C++ > are initialized before they are used, don't do it. :-) Refactoring sounds > expensive but in the long run it is cheaper than debugging interactions > between global variables.
Thanks David. Just venting here, but... $ ls *.h *.cpp | wc -l 269 $ grep class *.h *.cpp | wc -l 1332 Of 1300+ classes and nearly 270 source files, there are 5 globals that are sensitive to their initialization order. 3 are std::strings and 2 are C++ objects. Its *really* pathetic the C++ language lacks a mechanism for me to say "Object 1 depends upon String 1, 2, 3", and "Object 2 depends upon Object 1 and String 1, 2, 3". It's not like I'm asking the compiler to solve some NP-hard problem. It does not have to solve any problem. The language just needs the give me the ability to express a relative ordering among a handful of objects. The C/C++ committee does a lot of good, but they do some disingenuous things at times. They are the same bone heads who thought it was a good idea to crash a program when an assert fires. If you will recall, an assert is debugging and diagnostic information, and its disabled in release builds via the NDEBUG (no debug) macro. So an entire committee thought it was clever to crash a program under a debugger. Sigh... Jeff ------------------------------------------------------------------------------ _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users