not sure if this is a problem of Clang, or of GCC or the libstdc++ on Linux --
or if our expectation how C++ should behave are "broken". Maybe someone can shed
some light into this problem.
We tried compiling the GCC developed code base of our opensource project with
Clang. After fixing some minor problems to make the compilation succeed, we
noticed broken unit tests: Some application service, implemented as a
singleton, was instantiated multiple times in the Clang compiled executable.
I've tracked down the problem and extracted a demonstration. Initially I've
posted this as a question to stackoverflow; but maybe here is even a better
place to ask about such a somewhat slightly more involved situation.
Basically we have single instance of a class (a singleton factory) holding this
templated static variable (for the singleton instance). But when we use the
access function, which is inline, from multiple compilation units, different
memory locations are emitted for the same static variable. Accessing if from
within the same compilation unit works as expected.
We're observing this problem on Debian/stable 64bit (Clang-3.0 vs GCC-4.7);
we could reproduce same the behaviour on Debian/testing 32bit (Clang-3.2)
If necessary/helpful, I could repost the code here or provide additional