public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted
@ 2003-08-05 23:09 reichelt at gcc dot gnu dot org
  2003-08-05 23:23 ` [Bug c++/11814] " reichelt at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 21+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2003-08-05 23:09 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11814

           Summary: Code with missing "template" keyword wrongly accepted
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          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

Here's a spin-off from PR 6023:
The following code snippet is wrongly accepted by gcc:

-------------------------------------------
template <typename> struct A
{
    template <typename> void foo();
};

template <typename T> struct B
{
    template <int> void foo()
    {
        A<T>* p;
        p->foo<int>(); // wrong: should be "p->template foo<int>();"
    }
};
-------------------------------------------

Since "p" is dependent on the outer template parameter, we need a "template"
here. The parser wrongly accepts it because it finds "foo" in the current
scope which happens to be a template (although it's actually the wrong "foo"
that is considered for parsing). (This was pointed out by Nathan.)

To see this effect, just remove the "template <int>" from the second "foo"
and the compiler gioves an error message.

This bug affects all versions since gcc 2.95.x.


^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <bug-11814-1771@http.gcc.gnu.org/bugzilla/>]
[parent not found: <bug-11814-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-01-15 18:02 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
2003-08-05 23:23 ` [Bug c++/11814] " reichelt at gcc dot gnu dot org
2003-08-05 23:34 ` pinskia at physics dot uc dot edu
2003-08-05 23:36 ` pinskia at physics dot uc dot edu
2003-08-06  0:38 ` pinskia at physics dot uc dot edu
2003-08-08  0:07 ` reichelt at gcc dot gnu dot org
2003-08-23  1:09 ` dhazeghi at yahoo dot com
2003-11-07 16:34 ` reichelt at gcc dot gnu dot org
2003-11-23 11:36 ` lerdsuwa at gcc dot gnu dot org
2004-05-26 11:40 ` pinskia at gcc dot gnu dot org
2004-07-27 16:08 ` lerdsuwa at gcc dot gnu dot org
2005-03-17 13:59 ` pinskia at gcc dot gnu dot org
2005-03-25 20:38 ` redi at gcc dot gnu dot org
     [not found] <bug-11814-1771@http.gcc.gnu.org/bugzilla/>
2006-01-04  1:11 ` pinskia at gcc dot gnu dot org
2007-05-08 19:48 ` fang at csl dot cornell dot edu
2008-12-27  6:38 ` pinskia at gcc dot gnu dot org
2009-11-06 19:05 ` pinskia at gcc dot gnu dot org
     [not found] <bug-11814-4@http.gcc.gnu.org/bugzilla/>
2011-10-09 13:53 ` bangerth at gmail dot com
2011-10-09 14:02 ` redi at gcc dot gnu.org
2013-05-17 10:42 ` paolo.carlini at oracle dot com
2015-01-15 18:02 ` pinskia 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).