I have some legacy code and I need to add a new class for the message (which is irrelevant to my question). But it turns out that I need to declare an empty constructor in o
C++14 [temp.inst]/2:
Unless a member of a class template or a member template has been explicitly instantiated or explicitly specialized, the specialization of the member is implicitly instantiated when the specialization is referenced in a context that requires the member definition to exist; in particular, the initialization (and any associated side-effects) of a static data member does not occur unless the static data member is itself used in a way that requires the definition of the static data member to exist.
This says clearly that Message::test will not be initialized unless it is used in a way that requires its definition to exist.
The only expression in your program that would require the definition is test.dummy() in the constructor of Message ; so if that expression is removed then test must not be initialized.
For the case where test.dummy() is present, note that it is inside a template function, the constructor of Message. If this constructor is never instantiated, then test.dummy() will not be considered.
As pointed out by VTT, [class.ctor] says that the explicitly-defaulted constructor for A means that no constructor is defined unless an A is odr-used.
Your code doesn't odr-use an A, therefore A's constructor is not defined, therefore there is no invocation of base class constructor (which would only happen if if A's constructor was defined), therefore the constructor template Message() is not instantiated, therefore test is not required to exist.