This code compiles on MSVC but not on GCC, when testing on GodBolt.org
The Baz class is declared in the anonymous namespace, which makes GCC think it's a different class than what I then define below, but MSVC seems to connect them.
namespace { class Baz; }
class Foo { protected: int x; };
class Bar : public Foo { friend class Baz; };
namespace {
class Baz { void f() { Bar b; b.x = 42; } };
}
What is correct according to the standard?