[Bug c++/78923] New: bad error message about missing template argument

drepper.fsp+rhbz at gmail dot com gcc-bugzilla@gcc.gnu.org
Sat Dec 24 16:21:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78923

            Bug ID: 78923
           Summary: bad error message about missing template argument
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com
  Target Milestone: ---

Here is another case where the error message emitted by gcc (albeit, 6.2.1, I
don't have a more recent version handy):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T>
struct A;

template<typename T>
struct B {
  B(A<T>*);
};

template<typename T>
B<T>::B(A*) { // <-- should be:  B<T>::B(A<T>*) {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Notice the missing template argument.  The error message emitted is:
u.cc:10:8: error: expected constructor, destructor, or type conversion before
‘(’ token
 B<T>::B(A*) {
        ^


In comparison, clang++ emits:

u.cc:10:9: error: use of class template 'A' requires template arguments
B<T>::B(A*) {
        ^
u.cc:2:8: note: template is declared here
struct A;
       ^


More information about the Gcc-bugs mailing list