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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If the invalid special member is defined out of the class body, you get another
error:

template<typename T>
struct F
{
  F<T>();
};

template<typename T>
inline F<T>::F() { }


101032.C:4:8: error: expected unqualified-id before ‘)’ token
    4 |   F<T>();
      |        ^
101032.C:8:8: error: no declaration matches ‘F<T>::F()’
    8 | inline F<T>::F() { }
      |        ^~~~
101032.C:8:8: note: no functions named ‘F<T>::F()’
101032.C:2:8: note: ‘struct F<T>’ defined here
    2 | struct F
      |        ^

As well as improving the first error (which is the subject of this bug) maybe
the constructor could be parsed as though it had been written correctly, so
that the "no declaration matches" error doesn't happen. Compilation is already
going to fail, we don't need to also complain about the valid function
definition not matching anything.

Reply via email to