No modification of class A will affect how the declaration of A a(); parsed A a(); . The parser determines that it is a function declaration before it even wants to look at definition A In fact, the definition of A should not even be visible for the analysis of this statement; Adequate ad is enough.
However, compilers usually have a warning for this, and you can probably turn this into an error. For example, with clang you can use the flag -Werror = vexing-parse .
struct A; A a();
clang ++ -std = c ++ 11 -Weverything -Werror = vexing-parse main.cpp
main.cpp:6:8: error: empty parentheses interpreted as a function declaration [-Werror,-Wvexing-parse] A a(); ^~ main.cpp:6:8: note: replace parentheses with an initializer to declare a variable A a(); ^~ {} 1 error generated.
Although technically speaking, A a(); is not the syntax known as the most annoying parsing. It will be:
A a(B());
source share