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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2022-01-18 00:00:00         |2022-11-7

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I've just hit this myself and was quite confused by the diagnostic.

A realistic but still close to minimal reproducer is:

namespace x
{
  template<class T> struct S { };
}

struct A
{
  using S = ::x::S;
};


Unsurprisingly, you get the same error with -std=c++17 -fconcepts, because the
compiler seems to be treating the template-id as a placeholder-type-specifier,
maybe even as a type-constraint. Neither makes sense as the defining-type-id of
an alias-declaration.


With -std=c++14 you get a correct "invalid use of template-name" error, but
then an incorrect note about CTAD:

using.cc:8:13: error: invalid use of template-name 'x::S' without an argument
list
    8 |   using S = ::x::S;
      |             ^~
using.cc:8:13: note: class template argument deduction is only available with
'-std=c++17' or '-std=gnu++17'
using.cc:3:28: note: 'template<class T> struct x::S' declared here
    3 |   template<class T> struct S { };
      |                            ^

Although it's true that CTAD isn't available in C++14, it's not relevant here
because it couldn't be used here anyway (as evidenced by the fact it still
doesn't compie in C++17).


I would expect the same error for C++14 and C++17 (and ideally C++20 too) since
the code is invalid in exactly the same way in all cases. C++17 gives a similar
error to C++14 but with slightly different wording for some reason:

using.cc:8:13: error: missing template arguments after 'x::S'
    8 |   using S = ::x::S;
      |             ^~
      |               <>
using.cc:3:28: note: 'template<class T> struct x::S' declared here
    3 |   template<class T> struct S { };
      |                            ^


So we should:

1) fix the bogus "auto not allowed" when concepts are enabled;
2) harmonize the C++14 and C++17 wording about missing template args;
3) remove the bogus note about CTAD.

Reply via email to