public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101221] New: Inaccurate error message for wrong template alias
@ 2021-06-26 10:18 Theodore.Papadopoulo at inria dot fr
2022-01-18 13:27 ` [Bug c++/101221] " redi at gcc dot gnu.org
2022-11-07 9:53 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: Theodore.Papadopoulo at inria dot fr @ 2021-06-26 10:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101221
Bug ID: 101221
Summary: Inaccurate error message for wrong template alias
Product: gcc
Version: 10.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: Theodore.Papadopoulo at inria dot fr
Target Milestone: ---
Created attachment 51062
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51062&action=edit
Code showing the bug
The attached code produces the following message. The reference of the 'auto'
is at best surprising. Of course the code is wrong but the message is not very
helpful for identifying what is wrong.
mururoa-> g++ --std=c++20 test.C
test.C:16:18: error: ‘auto’ not allowed in alias declaration
16 | using OtherNew = One::AClass;
| ^~~
test.C:23:17: error: ‘auto’ not allowed in alias declaration
23 | using New = One::AClass;
| ^~~
clang does a slightly better job and at least at namespace level explains what
is wrong.
mururoa-> clang++ --std=c++20 test.C
test.C:16:23: error: use of class template 'One::AClass' requires template
arguments
using OtherNew = One::AClass;
^
test.C:4:43: note: template is declared here
template <Type type,typename T> class AClass;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
test.C:23:17: error: no type named 'AClass' in namespace 'One'; did you mean
'BClass'?
using New = One::AClass;
^~~~~~~~~~~
BClass
test.C:18:7: note: 'BClass' declared here
class BClass {
^
2 errors generated.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/101221] Inaccurate error message for wrong template alias
2021-06-26 10:18 [Bug c++/101221] New: Inaccurate error message for wrong template alias Theodore.Papadopoulo at inria dot fr
@ 2022-01-18 13:27 ` redi at gcc dot gnu.org
2022-11-07 9:53 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-18 13:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101221
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-01-18
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code from the attachment is:
namespace One {
typedef enum { A, B } Type;
template <Type type,typename T> class AClass;
template <typename T>
class AClass<A,T> { };
template <typename T>
class AClass<B,T> { };
}
typedef One::Type NewType;
template <NewType type,typename T>
using OtherNew = One::AClass;
class BClass {
typedef One::Type Type;
template <Type type,typename T>
using New = One::AClass;
};
With -std=gnu++17 we print:
101221.C:16:18: error: missing template arguments after 'AClass<...auto...>'
16 | using OtherNew = One::AClass;
| ^~~
101221.C:4:43: note: 'template<One::Type type, class T> class One::AClass'
declared here
4 | template <Type type,typename T> class AClass;
| ^~~~~~
101221.C:23:17: error: missing template arguments after 'AClass<...auto...>'
23 | using New = One::AClass;
| ^~~
101221.C:4:43: note: 'template<One::Type type, class T> class One::AClass'
declared here
4 | template <Type type,typename T> class AClass;
| ^~~~~~
With -std=gnu++20 we print:
101221.C:16:18: error: 'auto' not allowed in alias declaration
16 | using OtherNew = One::AClass;
| ^~~
101221.C:23:17: error: 'auto' not allowed in alias declaration
23 | using New = One::AClass;
| ^~~
Both diagnostics are wrong.
Clang prints the same error for C++17 and C++20.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/101221] Inaccurate error message for wrong template alias
2021-06-26 10:18 [Bug c++/101221] New: Inaccurate error message for wrong template alias Theodore.Papadopoulo at inria dot fr
2022-01-18 13:27 ` [Bug c++/101221] " redi at gcc dot gnu.org
@ 2022-11-07 9:53 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ 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=101221
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
namespace x
{
template<class T> struct S;
}
template<class T>
using S = x::S;
Which means this is the same as 104091. This is older, but that one has more
info so I'll close this as the dup.
*** This bug has been marked as a duplicate of bug 104091 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-07 9:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-26 10:18 [Bug c++/101221] New: Inaccurate error message for wrong template alias Theodore.Papadopoulo at inria dot fr
2022-01-18 13:27 ` [Bug c++/101221] " redi at gcc dot gnu.org
2022-11-07 9:53 ` 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).