I can remember that during the discussion about general attributes which finally lead to the new contextual keywords override and final it was suggested that compiler support for these ore some may be optional (I guess it would read in the standard text as “behavior is implementation-specific). But I can not find any trace about this optionality in the FDIS and the corrections afterwards.
But since not finding it is not proof, I have to ask: Is the support as described in 2.11p2, 9.2 and 10.3 of the FDIS for override and final obligatory for a conforming compiler?
Is it for example required that a conforming compiler rejects
class Foo {
void func() override; // Error: not virtual, 9.2p9
};
Or is it still conforming by ignoring override?
Yes, it’s required that
overrideis not ignored by a conforming implementation. First,overridecan only appear in the declaration of a virtual member function.9.2/9:
Second, a virtual function which doesn’t override a member function of a base class but is marked
overridemakes the program ill-formed.10.3/7:
As both are diagnosable rules of the standard it is illegal for a conforming compiler to ignore violations. (1.4/1)
The same reasoning applies to
finaland the relevant requirements are in 9 [class]/3 and 10.3 [class.virtual]/4.