Meador Inge wrote: > When 'obj1' and 'obj2' get linked into the final image there are no > guarantees on whose constructor (T::T or S::S) will be called first. > Sometimes folks write code where this initialization order matters. It > may cause strange behavior at run-time that is hard to pin down. This > may not be a problem in the LLVM code base, but it is the typical > problem that C++ devs run into with initialization of objects with > static storage duration.
Avoiding this problem is actually one of the original reasons for the popularity of the singleton design pattern in C++. With instantiation on first use, it helps ensure the constructors are all executed in the right order. (There are other problems with the double-checked locking required under certain aggressive compiler optimisation strategies, but the static initialisation ordering problem occurs even when optimisation is completely disabled). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com