From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 71EB938582A7; Mon, 7 Nov 2022 09:49:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71EB938582A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667814569; bh=EY84zYmDlBJzrKhwTOcrSnoHhNZOYxUGvryDxhKH99I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W2ZDBqCtNYY/o6Iku3uvhcguL3XS6xaYYnWTcE5KH9t9/GFtPsp75lvaBntrpfv84 eVKuiFgzPpsz9Z6Mez2p6rMtNZySXnoA8Vu8pY/K72KVVcsiZ+r8o/kLA2+x0rtrRt 0jldaFzpOg5Zt9fAsK1QiE8LjcoMF4bqGQHpyNA8= From: "redi at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104091 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2022-01-18 00:00:00 |2022-11-7 --- Comment #2 from Jonathan Wakely --- 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 struct S { }; } struct A { using S =3D ::x::S; }; Unsurprisingly, you get the same error with -std=3Dc++17 -fconcepts, becaus= e the compiler seems to be treating the template-id as a placeholder-type-specifi= er, maybe even as a type-constraint. Neither makes sense as the defining-type-i= d of an alias-declaration. With -std=3Dc++14 you get a correct "invalid use of template-name" error, b= ut then an incorrect note about CTAD: using.cc:8:13: error: invalid use of template-name 'x::S' without an argume= nt list 8 | using S =3D ::x::S; | ^~ using.cc:8:13: note: class template argument deduction is only available wi= th '-std=3Dc++17' or '-std=3Dgnu++17' using.cc:3:28: note: 'template struct x::S' declared here 3 | template struct S { }; | ^ Although it's true that CTAD isn't available in C++14, it's not relevant he= re 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) s= ince the code is invalid in exactly the same way in all cases. C++17 gives a sim= ilar 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 =3D ::x::S; | ^~ | <> using.cc:3:28: note: 'template struct x::S' declared here 3 | template 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.=