Noticed error-looking warning when was reducing unrelated boost ICE. Minimal reproducer: // $ cat bug.cpp extern struct grammar *target_grammar; template <typename T> void define(void) { target_grammar->derived(); } $ g++-11.0.0 -c bug.cpp; echo $? bug.cpp: In function 'void define()': bug.cpp:3:57: warning: invalid use of incomplete type 'struct grammar' 3 | template <typename T> void define(void) { target_grammar->derived(); } | ^~ bug.cpp:1:15: note: forward declaration of 'struct grammar' 1 | extern struct grammar *target_grammar; | ^~~~~~~ 0 $ clang++ -c bug.cpp; echo $? clang++ bug.cpp:3:57: error: member access into incomplete type 'struct grammar' template <typename T> void define(void) { target_grammar->derived(); } ^ bug.cpp:1:15: note: forward declaration of 'grammar' extern struct grammar *target_grammar; ^ 1 error generated. 1 I read the diagnostic with "invalid use" as clearly incorrect code. Should g++ error out instead of generating a warning?
It is only a warning (pedwarn in particular, error with -pedantic-errors) in the uninstantiated template, if you instantiate the template and the type is still incomplete, you get hard error.
That makes sense. If it's a valid C++ I'm fine with closing the bug as RESOLVED/INVALID.