public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104091] -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
Date: Mon, 07 Nov 2022 09:49:28 +0000	[thread overview]
Message-ID: <bug-104091-4-zT6bBt1lvj@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104091-4@http.gcc.gnu.org/bugzilla/>

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.

  parent reply	other threads:[~2022-11-07  9:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-18 11:00 [Bug c++/104091] New: " nickhuang99 at hotmail dot com
2022-01-18 11:10 ` [Bug c++/104091] " pinskia at gcc dot gnu.org
2022-11-07  9:49 ` redi at gcc dot gnu.org [this message]
2022-11-07  9:53 ` redi at gcc dot gnu.org
2022-11-07  9:55 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104091-4-zT6bBt1lvj@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).