Your program has undefined behavior. Paragaph 3.2/6 of the C++11 Standard specifies:
There can be more than one definition of a class type (Clause 9), […] in a program provided that each definition
appears in a different translation unit, and provided the definitions satisfy the following requirements. Given
such an entity namedD
defined in more than one translation unit, then […]
And what follows is a list of requirements that your program is indeed violating. However, at the end of the list, this is mentioned:
[…] If the definitions of
D
satisfy all these requirements,
then the program shall behave as if there were a single definition ofD
. If the definitions ofD
do not satisfy
these requirements, then the behavior is undefined.