error: a class-key must be used when declaring a friend in gcc

137 views Asked by At

I get an error with this code

struct Foo { };

struct Bar { friend Foo; };

int main() { }
error: a class-key must be used when declaring a friend
error: friend declaration does not name a class of function

According to answers here this is just what the standard mandates. However, what puzzles me is that I get the error with gcc 4.4.7 but not with the newer gcc 4.8.5 (in both cases no compiler flags, but only defaults, ie no C++11). Why is that?

Has gcc decided to drop its standard compliance on this point, because thats what all others compilers do, or what is going on here?

And if possible, I would like to know if I can get gcc 4.8 to issue an error on that (or alternatively make gcc 4.4 swallow it without complaints).

0

There are 0 answers