[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2017-08-17 00:00:00 |2018-8-29 --- Comment #3 from Jonathan Wakely --- The first example was fixed for GCC 4.8.0 The second started saying "template argument 1 is invalid" in GCC 4.8.0 and stopped also saying "invalid type in declaration" for GCC 5.1.0 The caret locations for "template argument 1" are poor though, they point to the end of the template argument list. For the second and third ones Clang gives a nicer diagnostic: 45113.cc:2:15: error: type-id cannot have a name typedef U A; ^ 45113.cc:2:21: error: type-id cannot have a name typedef U A; ^ 2 errors generated. That's accurate and helpful. We could even add a fix-it to remove those names.
[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113 Eric Gallager changed: What|Removed |Added CC||dmalcolm at gcc dot gnu.org, ||dodji at gcc dot gnu.org --- Comment #2 from Eric Gallager --- cc-ing diagnostics maintainers
[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113 Eric Gallager changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-17 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Gallager --- Redoing https://gcc.gnu.org/ml/gcc-bugs/2017-08/msg01665.html Eric Gallager changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-14 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Gallager --- (In reply to Roman Kononov from comment #0) > $cat test1.cpp > template struct is_same { static bool const > value=false; }; > template struct is_same{ static bool const value=true; }; > template struct U {}; > struct Q { typedef U C; }; > typedef char check[is_same ::value ? 1 : -1]; > > $g++ -std=gnu++0x -c test1.cpp && echo $? > 0 > > In 14.3.1, the Standard says: "A template-argument for a template-parameter > which is a type shall be a type-id." The test must fail compilation, and > Q::C can not be int. This now fails with: $ /usr/local/bin/g++ -c -std=gnu++0x 45113.cc 45113.cc:4:33: error: template argument 1 is invalid struct Q { typedef U C; }; ^ $ > > $cat test2.cpp > template struct U {}; > typedef U B; > > $g++ -std=gnu++0x -c test2.cpp > test2.cpp:2:25: error: invalid type in declaration before ';' token > > This message is confusing. This message is now: $ /usr/local/bin/g++ -c -std=gnu++0x 45113_2.cc 45113_2.cc:2:22: error: template argument 1 is invalid typedef U B; ^ $ > > $cat test3.cpp > template struct U {}; > typedef U A; > > $g++ -c test3.cpp > test3.cpp:2:22: error: wrong number of template arguments (1, should be 2) > test3.cpp:1:40: error: provided for 'template struct U' > test3.cpp:2:25: error: invalid type in declaration before ';' token > > These messages are confusing. This message is now: $ /usr/local/bin/g++ -c -std=gnu++0x 45113_3.cc 45113_3.cc:2:22: error: wrong number of template arguments (1, should be 2) typedef U A; ^ 45113_3.cc:1:40: note: provided for ‘template struct U’ template struct U {}; ^ $ Which I guess is still kinda confusing. So test1.cpp and test2.cpp are fixed, but confirming for test3.cpp.
[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113 --- Comment #2 from Jonathan Wakely --- Clang has a nice error for test3 45113_3.cc:2:15: error: type-id cannot have a name typedef U A; ^ 45113_3.cc:2:21: error: type-id cannot have a name typedef U A; ^ 2 errors generated.
[Bug c++/45113] absent or confusing diagnostics of invalid template argument list in implicit template class instantiation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45113 Eric Gallager changed: What|Removed |Added Keywords||diagnostic Status|UNCONFIRMED |NEW Last reconfirmed||2017-08-14 CC||egallager at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Eric Gallager --- (In reply to Roman Kononov from comment #0) > $cat test1.cpp > template struct is_same { static bool const > value=false; }; > template struct is_same{ static bool const value=true; }; > template struct U {}; > struct Q { typedef U C; }; > typedef char check[is_same ::value ? 1 : -1]; > > $g++ -std=gnu++0x -c test1.cpp && echo $? > 0 > > In 14.3.1, the Standard says: "A template-argument for a template-parameter > which is a type shall be a type-id." The test must fail compilation, and > Q::C can not be int. This now fails with: $ /usr/local/bin/g++ -c -std=gnu++0x 45113.cc 45113.cc:4:33: error: template argument 1 is invalid struct Q { typedef U C; }; ^ $ > > $cat test2.cpp > template struct U {}; > typedef U B; > > $g++ -std=gnu++0x -c test2.cpp > test2.cpp:2:25: error: invalid type in declaration before ';' token > > This message is confusing. This message is now: $ /usr/local/bin/g++ -c -std=gnu++0x 45113_2.cc 45113_2.cc:2:22: error: template argument 1 is invalid typedef U B; ^ $ > > $cat test3.cpp > template struct U {}; > typedef U A; > > $g++ -c test3.cpp > test3.cpp:2:22: error: wrong number of template arguments (1, should be 2) > test3.cpp:1:40: error: provided for 'template struct U' > test3.cpp:2:25: error: invalid type in declaration before ';' token > > These messages are confusing. This message is now: $ /usr/local/bin/g++ -c -std=gnu++0x 45113_3.cc 45113_3.cc:2:22: error: wrong number of template arguments (1, should be 2) typedef U A; ^ 45113_3.cc:1:40: note: provided for ‘template struct U’ template struct U {}; ^ $ Which I guess is still kinda confusing. So test1.cpp and test2.cpp are fixed, but confirming for test3.cpp.