I have come across a situation in our codebase where two DLLs that link to each other, both link statically to the same static library. This results in both DLLs pulling in a separate copy of the static library when they are linked.
In this particular situation, the static library contains a class that is intended to be a singleton... But since both DLLs pull in their own copy, when DLL1 attempts to access the singleton it gets a different instance than DLL2! This is causing lots of issues with program state and initialization because both libraries see a different state of the program.
I understand what is happening is BAD and is a bug in the program. But is it actually in the realm of "undefined behavior"? Does this violate the One Definition Rule?
What about the situation where the static library does not contain a singleton. Is it perfectly okay then, or is that still a problem? (If it violates the ODR, I assume it is still a problem.)
dll
created its own instance of a static variable. – Kopeck