This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11815] New: ICE with missing template keyword
- From: "reichelt at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Aug 2003 23:16:55 -0000
- Subject: [Bug c++/11815] New: ICE with missing template keyword
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11815
Summary: ICE with missing template keyword
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Keywords: ice-on-invalid-code, error-recovery, diagnostic
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: reichelt at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
This is a spin-off from PR 6023:
Consider the following invalid code (which is missing a "template"
keyword righ before "X" in line 5):
-------------------------------------------
template <typename> struct A;
template <typename T> struct B
{
template <int> void foo(const typename A<T>::X<T,T>::Y&);
template <typename U> void bar(U x) { foo<0>(x); }
};
-------------------------------------------
Compiling this with mainline, one gets the following error message:
bug.cc:5: error: expected primary-expression
bug.cc:5: error: expected primary-expression
bug.cc:5: error: `::Y' has not been declared
bug.cc:5: error: expected primary-expression
bug.cc:5: error: variable or field `foo' declared void
bug.cc:5: error: ISO C++ forbids initialization of member `foo'
bug.cc:5: error: making `foo' static
bug.cc:5: error: ISO C++ forbids in-class initialization of non-const static
member `foo'
bug.cc:5: error: template declaration of `int B<T>::foo'
bug.cc: In member function `void B<T>::bar(U)':
bug.cc:6: internal compiler error: in cp_parser_template_id, at cp/parser.c:
7516
Please submit a full bug report, [etc.]
This is rewarded with three keywords: "ice-on-invalid-code",
"error-recovery" (since the ICE happens after a error message),
and "diagnostic" (since the error message is not very helpful -
we are missing just one "template", remember).
Nevertheless, this is actually an improvement since the code was wrongly
accepted by gcc 2.95.x - 3.3.x.
Btw, by varying the declaration of foo (i.e. removing "&", "const", or "::Y")
one can change the error message a little.