https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97922
Bug ID: 97922 Summary: inline namespace caused confusing error message Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: harry.linxd at gmail dot com Target Milestone: --- For a type that's defined in inline namespace, forward declaration and definition appear in the same scope cause confusing error messages, while clang++'s diagnostic messages are more clear ``` $cat type1.h namespace test { inline namespace internal { struct Type1 { Type1() = default; }; } } ``` ``` $cat test.cpp #include <utility> #include "./type1.h" namespace test { struct Type1; //Type1 is actually in an inline namespace } using Type = std::pair<test::Type1, int>; void f(Type& t); ``` ``` $ g++ -I. test.cpp test.cpp:8:40: error: template argument 1 is invalid 8 | using Type = std::pair<test::Type1, int>; | ^ test.cpp:10:6: error: variable or field 'f' declared void 10 | void f(Type& t); | ^ test.cpp:10:8: error: 'Type' was not declared in this scope 10 | void f(Type& t); | ^~~~ test.cpp:10:14: error: 't' was not declared in this scope 10 | void f(Type& t); | ^ ``` Here gcc's error message is sort of confusing, while clang's diagnostic message is more straight: ``` $ clang++ -I. test.cpp test.cpp:8:30: error: reference to 'Type1' is ambiguous using Type = std::pair<test::Type1, int>; ^ ././type1.h:3:8: note: candidate found by name lookup is 'test::internal::Type1' struct Type1 { ^ test.cpp:5:8: note: candidate found by name lookup is 'test::Type1' struct Type1; ^ 1 error generated. ```