To answer it as an actual technical question:
According to C++23 final draft N4950, This code should not compile. The program is ill-formed.
[class.local]/3 states that
If class X is a local class a nested class Y may be declared in class X and later defined in the definition of class X or be later defined in the same scope as the definition of class X. A class nested within a local class is a local class.
This means that B is also a local class, and this code attempts to define it neither in the definition of class A nor in the same scope as the definition of class A (which is the function scope of f).
The using declaration declares an alias A of the local class A, but it does not change the fact that the class A is a local class. The A introduced by the alias declaration is another name, though it spells "A".
The "internal compiler error" of GCC is not compile error, but a potential GCC bug (that's why it suggests you sending a bug report).
P.S. I'm not quite sure because [class.local]/3 uses the word "may". I did not find any other paragraph addressing this with a stronger tone.
I also found the following code compiles differently among GCC, Clang and MSVC:
auto f() {
struct A {
A();
};
return A{};
}
using A = decltype(f());
A::A() = default;
int main() {}
godbolt