public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
@ 2022-01-18 11:00 nickhuang99 at hotmail dot com
2022-01-18 11:10 ` [Bug c++/104091] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: nickhuang99 at hotmail dot com @ 2022-01-18 11:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104091
Bug ID: 104091
Summary: -std=c++20 causing meaningless error message "'auto'
not allowed in alias declaration" which should be
"missing template arguments after ..."
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nickhuang99 at hotmail dot com
Target Milestone: ---
considering following snippet of code:
template<typename T, template<typename...>typename Template>
struct Specialization{};
template<template<typename...>typename Template, typename...Args>
struct Specialization<Template<Args...>, Template>{
using type=Template;
};
Using -std=c++20 gives meaningless error message of "'auto' not allowed in
alias declaration". While -std=c++17 or before all give correct error message:
"missing template arguments after 'Template<...auto...>'". And -std=c++14 is
even better with "invalid use of template-name 'Template' without an argument
list".
See https://godbolt.org/z/Wb9nKzcPT
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104091] -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
2022-01-18 11:00 [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..." nickhuang99 at hotmail dot com
@ 2022-01-18 11:10 ` pinskia at gcc dot gnu.org
2022-11-07 9:49 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-18 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104091
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-01-18
Ever confirmed|0 |1
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed reduced to just:
template<typename> class Tt;
using type=Tt;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104091] -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
2022-01-18 11:00 [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..." 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
2022-11-07 9:53 ` redi at gcc dot gnu.org
2022-11-07 9:55 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-07 9:49 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104091] -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
2022-01-18 11:00 [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..." 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
@ 2022-11-07 9:53 ` redi at gcc dot gnu.org
2022-11-07 9:55 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-07 9:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104091
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Theodore.Papadopoulo@inria.
| |fr
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 101221 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/104091] -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..."
2022-01-18 11:00 [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..." nickhuang99 at hotmail dot com
` (2 preceding siblings ...)
2022-11-07 9:53 ` redi at gcc dot gnu.org
@ 2022-11-07 9:55 ` redi at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-07 9:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104091
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
A slight variation from PR 101221:
template<class T> struct S;
template<class T> using SS = S;
For comparison, Clang and EDG give exactly the same diagnostic for all examples
above irrespective of C++14/17/20 mode.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-07 9:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 11:00 [Bug c++/104091] New: -std=c++20 causing meaningless error message "'auto' not allowed in alias declaration" which should be "missing template arguments after ..." 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
2022-11-07 9:53 ` redi at gcc dot gnu.org
2022-11-07 9:55 ` redi at gcc dot gnu.org
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).