I have a small program with such simple code:
namespace override
{
using final = void();
}
namespace final
{
using override = void(int);
struct final
{
virtual override override;
virtual ::override::final override;
};
}
int main()
{
struct final final : ::final::final
{
::final::override override override final;
::override::final override final override;
};
// doesn't compile
struct override : final
{
};
}
Unfortunately it doesn't compile. I tried to compile it with following pieces of code:
// 1
struct override final
{
};
// 2
override : final
{
};
And both of these variants compile fine. Is it an error in my compiler (clang 3.4)? I can't also understand why my original code doesn't compile.
See live example.
Update: It was an April Fool's day joke, of course. Thanks to all who participated in the discussion. I also thank @ecatmur for his exact but too serious answer.
I wanted to get the code that would have looked strange and at the same time would have compiled with one compiler at least (because it would have given respectability to my question). So my goal was not to create a standard-compliant code. But as @Johannes Schaub - litb noted in comments this code has at least one problem which make it ill-formed. The line virtual override override; is a violation the following rule (see paragraph [basic.scope.class] 3.3.7/1 of the standard):
A name
Nused in a classSshall refer to the same declaration in its context and when re-evaluated in the completed scope ofS. No diagnostic is required for a violation of this rule.
As I can see it can be rewritten as virtual ::final::override override; to become a standard-compliant.
error: base 'final' is marked 'final'. What keywords do you mean?finalas final which means you can not use it as a base class ... do you have reason to believe this should not be the case?