public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-06  6:46 carlo
  0 siblings, 0 replies; 7+ messages in thread
From: carlo @ 2001-06-06  6:46 UTC (permalink / raw)
  To: gcc-gnats; +Cc: vincent

>Number:         3063
>Category:       c++
>Synopsis:       Explicit specification of a template-argument gives syntax error inside a template function.
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 06 06:46:02 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Vincent Penquerc'h
>Release:        All releases
>Organization:
>Environment:

>Description:
For some reason, g++ doesn't understand explicit
template parameter specification inside a template
function.

This error occurs with 2.95.1 and higher (didn't test
it with older versions).

~>g++ -v -c test.cc
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.0)
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cpp0 -lang-c++ -D__GNUG__=2 -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__tune_i386__ test.cc /tmp/ccPIZJO5.ii
GNU CPP version 2.96 20000731 (Red Hat Linux 7.0) (cpplib)
 (i386 Linux/ELF)
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-3
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/2.96/cc1plus /tmp/ccPIZJO5.ii -quiet -dumpbase test.cc -version -o /tmp/ccgcwPq3.s
GNU C++ version 2.96 20000731 (Red Hat Linux 7.0) (i386-redhat-linux) compiled by GNU C version 2.96 20000731 (Red Hat Linux 7.0).
test.cc: In function `void bar ()':
test.cc:15: parse error before `>'
~>g++-3.0 -v -c test.cc
Reading specs from /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: /usr/src/gcc/gcc-cvs-3.0/configure --prefix=/usr/local/gcc-3.0 --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++ --enable-debug
Thread model: single
gcc version 3.0 20010523 (prerelease)
 /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cc -D__GNUG__=3 -D_GNU_SOURCE -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cc -version -o /tmp/ccMiEhFW.s
GNU CPP version 3.0 20010523 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010523 (prerelease) (i686-pc-linux-gnu)
        compiled by GNU C version 3.0 20010523 (prerelease).
ignoring nonexistent directory "/usr/local/gcc-3.0/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc-3.0/include/g++-v3
 /usr/local/gcc-3.0/include/g++-v3/i686-pc-linux-gnu
 /usr/local/gcc-3.0/include/g++-v3/backward
 /usr/local/include
 /usr/local/gcc-3.0/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/include
End of search list.
test.cc: In function `void bar()':
test.cc:15: parse error before `>' token


>How-To-Repeat:
Compile the file 'test.cc' given below as g++ -c test.cc

struct A {
  template<typename T> void func(void) { new T; }
};
 
void foo(void)
{
  A a;
  a.func<char>();               // Not an error
}
 
template<typename T>
void bar(void)
{
  A a;
  a.func<char>();               // Syntax Error (line 15)
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-08  2:36 Vincent Penquerc'h
  0 siblings, 0 replies; 7+ messages in thread
From: Vincent Penquerc'h @ 2001-06-08  2:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3063; it has been noted by GNATS.

From: "Vincent Penquerc'h" <vincent@qubesoft.com>
To: <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
Cc: <nobody@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org>
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function. 
Date: Fri, 8 Jun 2001 10:28:21 +0100

 Gabriel Dos Reis wrote:
 
 > That is nonetheless an unfortunate workaround for a bug in the parser.
 > Anyway, that is one of the things we plan to fix in the parser rewrite
 > (soon). 
 
 Nice to hear that. 3.1 or later ?
 
 Another thing that might be of interest is my original testcase, which
 shows that the code is accepted when its body is inlined in the class
 definition, but not when it is defined (still inline) outside of it.
 
 The in-class verson compiles with 2.95, 2.95.3 and 3.0, the out-of-class
 version compiles with GCC 2.95, but not with 2.95.3 nor CodeSourcery's web
 GCC 3.0 compiler. I did not try those with 2.95.1 nor 2.95.2.
 
 I was told it was because trying to overload on the return value, which
 is not allowed, but since I explicitely qualify the template arguments,
 there is no need for resolution. Even if this code is not valid, I'd be
 tempted to say that this discrepancy is a compiler bug, and I'd like to
 know what you GCC C++ hackers think of it.
 
 Thanks for your help
 
 
 class Rep {
 public:
   template<class Res> inline const Res* Get() const;// {return 0;}
 };
 
 class Manager {
   Rep rep;
 public:
   template<class Res> const Res *Get() const;// {return rep.Get<Res>();}
 };
 
 #if 1
 template<class Res> inline const Res* Rep::Get() const
 {
   return 0;
 }
 
 template<class Res> const Res *Manager::Get() const
 {
   return rep.Get<Res>();
 }
 #endif
 
 class Res {};
 
 int main()
 {
   Manager m;
   m.Get<Res>();
   return 0;
 }
 
 -- 
 Vincent Penquerc'h


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-07 15:46 Gabriel Dos Reis
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Dos Reis @ 2001-06-07 15:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3063; it has been noted by GNATS.

From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: Phil Edwards <pedwards@disaster.jaj.com>
Cc: nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
Date: 08 Jun 2001 00:41:24 +0200

 Phil Edwards <pedwards@disaster.jaj.com> writes:
 
 | The following reply was made to PR c++/3063; it has been noted by GNATS.
 | 
 | From: Phil Edwards <pedwards@disaster.jaj.com>
 | To: Martin Sebor <sebor@roguewave.com>
 | Cc: gcc-gnats@gcc.gnu.org
 | Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
 | Date: Thu, 7 Jun 2001 16:35:23 -0400
 | 
 |  On Thu, Jun 07, 2001 at 09:46:01PM -0000, Martin Sebor wrote:
 |  >  Only in a dependent context. `a' here doesn't depend on a template
 |  >  parameter so `template' isn't required. I believe this is a known
 |  >  bug in the parser (someone else acknowledged it on this list in
 |  >  the past).
 |  
 |  After reading 14.2 I think you're right.  Note that adding 'template'
 |  as I wrote it, still works around the problem.
 
 That is nonetheless an unfortunate workaround for a bug in the parser.
 Anyway, that is one of the things we plan to fix in the parser rewrite
 (soon). 
 
 -- Gaby


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax   error inside a template function.
@ 2001-06-07 15:46 Gabriel Dos Reis
  0 siblings, 0 replies; 7+ messages in thread
From: Gabriel Dos Reis @ 2001-06-07 15:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3063; it has been noted by GNATS.

From: Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>
To: Martin Sebor <sebor@roguewave.com>
Cc: nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax   error inside a template function.
Date: 08 Jun 2001 00:39:20 +0200

 Martin Sebor <sebor@roguewave.com> writes:
 
 | The following reply was made to PR c++/3063; it has been noted by GNATS.
 | 
 | From: Martin Sebor <sebor@roguewave.com>
 | To: pme@gcc.gnu.org
 | Cc: gcc-gnats@gcc.gnu.org
 | Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax 
 |  error inside a template function.
 | Date: Thu, 07 Jun 2001 15:44:48 -0600
 | 
 |  pme@gcc.gnu.org wrote:
 |  > 
 |  > Synopsis: Explicit specification of a template-argument gives syntax error inside a template function.
 |  > 
 |  > State-Changed-From-To: open->closed
 |  > State-Changed-By: pme
 |  > State-Changed-When: Thu Jun  7 14:35:40 2001
 |  > State-Changed-Why:
 |  > 
 |  >     Not a bug.  The parser thinks that < means 'less than'.
 |  >     You're required by the c++ standard to write
 |  > 
 |  >         a.template func<char>();     // line 15
 |  
 |  Only in a dependent context. `a' here doesn't depend on a template
 |  parameter so `template' isn't required. I believe this is a known
 |  bug in the parser (someone else acknowledged it on this list in
 |  the past).
 
 Yes, that is a known bug, as I said a similar bug report.
 
 -- Gaby


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-07 14:56 Phil Edwards
  0 siblings, 0 replies; 7+ messages in thread
From: Phil Edwards @ 2001-06-07 14:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3063; it has been noted by GNATS.

From: Phil Edwards <pedwards@disaster.jaj.com>
To: Martin Sebor <sebor@roguewave.com>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
Date: Thu, 7 Jun 2001 16:35:23 -0400

 On Thu, Jun 07, 2001 at 09:46:01PM -0000, Martin Sebor wrote:
 >  Only in a dependent context. `a' here doesn't depend on a template
 >  parameter so `template' isn't required. I believe this is a known
 >  bug in the parser (someone else acknowledged it on this list in
 >  the past).
 
 After reading 14.2 I think you're right.  Note that adding 'template'
 as I wrote it, still works around the problem.
 
 -- 
 pedwards at disaster dot jaj dot com  |  pme at sources dot redhat dot com
 devphil at several other less interesting addresses in various dot domains
 The gods do not protect fools.  Fools are protected by more capable fools.


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-07 14:46 Martin Sebor
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Sebor @ 2001-06-07 14:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/3063; it has been noted by GNATS.

From: Martin Sebor <sebor@roguewave.com>
To: pme@gcc.gnu.org
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/3063: Explicit specification of a template-argument gives syntax 
 error inside a template function.
Date: Thu, 07 Jun 2001 15:44:48 -0600

 pme@gcc.gnu.org wrote:
 > 
 > Synopsis: Explicit specification of a template-argument gives syntax error inside a template function.
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: pme
 > State-Changed-When: Thu Jun  7 14:35:40 2001
 > State-Changed-Why:
 > 
 >     Not a bug.  The parser thinks that < means 'less than'.
 >     You're required by the c++ standard to write
 > 
 >         a.template func<char>();     // line 15
 
 Only in a dependent context. `a' here doesn't depend on a template
 parameter so `template' isn't required. I believe this is a known
 bug in the parser (someone else acknowledged it on this list in
 the past).
 
 Regards
 Martin
 
 > 
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3063&database=gcc


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

* Re: c++/3063: Explicit specification of a template-argument gives syntax error inside a template function.
@ 2001-06-07 14:35 pme
  0 siblings, 0 replies; 7+ messages in thread
From: pme @ 2001-06-07 14:35 UTC (permalink / raw)
  To: carlo, gcc-bugs, gcc-prs, nobody, vincent

Synopsis: Explicit specification of a template-argument gives syntax error inside a template function.

State-Changed-From-To: open->closed
State-Changed-By: pme
State-Changed-When: Thu Jun  7 14:35:40 2001
State-Changed-Why:
    
    Not a bug.  The parser thinks that < means 'less than'.
    You're required by the c++ standard to write
    
        a.template func<char>();     // line 15

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3063&database=gcc


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

end of thread, other threads:[~2001-06-08  2:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-06  6:46 c++/3063: Explicit specification of a template-argument gives syntax error inside a template function carlo
2001-06-07 14:35 pme
2001-06-07 14:46 Martin Sebor
2001-06-07 14:56 Phil Edwards
2001-06-07 15:46 Gabriel Dos Reis
2001-06-07 15:46 Gabriel Dos Reis
2001-06-08  2:36 Vincent Penquerc'h

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