public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16234] New: Bad diagnostic
@ 2004-06-27 17:41 igodard at pacbell dot net
2004-06-27 18:14 ` [Bug c++/16234] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: igodard at pacbell dot net @ 2004-06-27 17:41 UTC (permalink / raw)
To: gcc-bugs
template<typename T> struct A {
template<typename U> void Foo(){} };
template<typename V>struct B {
void Bar(V* v) {
v->template Foo<int>();
v->Foo<int>();
}
};
int main() {
A<bool> a;
B<A<bool> > b;
b.Bar(&a);
}
gets you:
~/ootbc/common/test/src$ g++ foo.cc
foo.cc: In member function `void B<V>::Bar(V*)':
foo.cc:6: error: expected primary-expression before "int"
foo.cc:6: error: expected `;' before "int"
The actual problem is the missing explicit "template" qualification. Surely the compiler can recognize "<int>" as a template argument list in this case for purposes of the diagnostic. There is an eroror here - the rules do require a diagnostic - but the compiler could be a lot more graceful about what it says when it doesn't get the required qualifier.
I grant that templates with data arguments cannot be as easily recognized in such a context. In:
template<typename T> struct A {
template<int I> void Foo(){} };
template<typename V>struct B {
void Bar(V* v) {
v->template Foo<int>();
v->Foo<5>();
}
};
int main() {
A<bool> a;
B<A<bool> > b;
b.Bar(&a);
}
ot is probably too tough to figure out what is wrong (operator <(void(*)(), int)???, although that is very unlikely and would be syntactically wrong here even if the operator existed). Just assuming that "anyTemplateFunc<" is the start of a template invocation would give the best diagnostic most likely, and the compiler can complain that the assumption is not permitted by the lanhuage. One of the fameous "ISO C++ requires that the invocation 'Foo<int>' be explicitly qualified as 'template Foo<int>'" messages, maybe?
Ivan
--
Summary: Bad diagnostic
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16234
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/16234] Bad diagnostic
2004-06-27 17:41 [Bug c++/16234] New: Bad diagnostic igodard at pacbell dot net
@ 2004-06-27 18:14 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-27 18:14 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-27 18:09 -------
I should note that the template keyword is required by the standard, this is dup of bug 16233.
Note a->b the type of b is not known untill the template is instantiated so a->b < 5 would be valid
until then and will cause an error when the template is instantiated.
*** This bug has been marked as a duplicate of 16233 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16234
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-27 18:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-27 17:41 [Bug c++/16234] New: Bad diagnostic igodard at pacbell dot net
2004-06-27 18:14 ` [Bug c++/16234] " pinskia at gcc dot gnu dot 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).