LUMIERA.clone/research/clang-static-init-1.cpp
Ichthyostega cdb3d3045a BUG: Clang shows a problem when accessing templated static variable through separate compilation units
this is really creepy: the same(!) instance of the singleton factory
sees different addresses of the class static variable, depending on
the compilation unit.

Please note that the type of the concrete factory function is *erased*
when exiting the constructor function of ConfigurableHolder
2013-10-06 23:17:18 +02:00

28 lines
588 B
C++

#include "clang-static-init.hpp"
test::Subject&
localFunction()
{
return test::fab.get();
}
int
main (int, char**)
{
cout << "\nStart Testcase: invoking two instances of the configurable singleton factory...\n\n";
test::Subject& ref1 = test::fab.get();
test::Subject& sub2 = test::fabricate(); ///NOTE: invoking get() from within another compilation unit reveales the problem
test::Subject& sub3 = localFunction();
cout << "sub1=" << &ref1
<< "\nsub2="<< &sub2
<< "\nsub3="<< &sub3
<< "\n";
return 0;
}