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; 13+ 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] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  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 ` reichelt at gcc dot gnu dot org
  2003-08-05 23:34 ` pinskia at physics dot uc dot edu
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2003-08-05 23:23 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


reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |6023
              nThis|                            |


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  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
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-05 23:34 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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-05 23:34 -------
I can confirm this on the mainline (20030805).
Here is a more interesting example where the two template function foo take two different 
template arguments:
template <typename> struct A
{
    template <int> void foo();
};
template <typename T> struct B
{
    template <int> void foo()
    {
        A<T>* p;
        p->foo<1>(); // wrong: should be "p->template foo<1>();"  
    }
};


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  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
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-05 23:36 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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-05 23:36:55
               date|                            |


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  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
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-06  0:38 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



------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-06 00:38 -------
My comment in 1 is wrong, the example I gave is where they have the same type 
template agruments not different.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  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
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2003-08-08  0:07 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



------- Additional Comments From reichelt at gcc dot gnu dot org  2003-08-08 00:07 -------
Maybe related to PR 10200.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  1: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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4                         |---


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2003-11-07 16:34 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


reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |12944
              nThis|                            |


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2003-11-23 11:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lerdsuwa at gcc dot gnu dot org  2003-11-23 11:36 -------
Probably problem deciding if a name is dependent.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |lerdsuwa at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-26 11:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-25 14:16 -------
Hmm, ICC 6.0 accepts the code also (even in strict mode).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2004-05-05 03:49:06         |2004-05-25 14:16:38
               date|                            |


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2004-07-27 16:08 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|lerdsuwa at gcc dot gnu dot |unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  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
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-03-17 13:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-03-17 13:58 -------
*** Bug 20516 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |topiolli at ee dot oulu dot
                   |                            |fi


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/11814] Code with missing "template" keyword wrongly accepted
  2003-08-05 23:09 [Bug c++/11814] New: Code with missing "template" keyword wrongly accepted reichelt at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2005-03-17 13:59 ` pinskia at gcc dot gnu dot org
@ 2005-03-25 20:38 ` redi at gcc dot gnu dot org
  11 siblings, 0 replies; 13+ messages in thread
From: redi at gcc dot gnu dot org @ 2005-03-25 20:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From redi at gcc dot gnu dot org  2005-03-25 20:38 -------
This can be simplified to:

template <class T> void f()
{
  T t;
  t.f<>(0); //should be t.template f<>(0);
}

If either 'f' is renamed g++ correctly reports an error.

Comeau's online compiler behaves the same.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-03-25 20:38 UTC | newest]

Thread overview: 13+ 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

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).