Bug 238468 - "syntax error before `>' token" when compiling, using templates
Summary: "syntax error before `>' token" when compiling, using templates
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3
Version: 3.7
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-04-30 18:47 UTC by Mike
Modified: 2007-11-17 01:14 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-04-30 19:43:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Mike 2007-04-30 18:47:39 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Mike 2007-04-30 18:49:38 UTC
Sorry, hit enter too soon.  It seems that inside of a templated function call, a
templated member function will make it think it's a syntax error.  This work
fine in RHEL4, but does not in RHEL3, with the newest gcc-c++ and libraries.

Error:

[root@linuxdevhq01 test]$ g++ test.cpp
test.cpp: In function `void f()':
test.cpp:13: syntax error before `>' token


Code:

#include <iostream>

struct Object {
  template <typename T>
  T* g() {
    return NULL;
  }
};

template <typename T>
void f() {
  Object o;
  T* d = o.g<T>();
}

int main() {
  f<int>();
  return EXIT_SUCCESS;
}

Comment 2 Jakub Jelinek 2007-04-30 19:43:34 UTC
Please use
T* d = o.template g<T>();
instead in RHEL3.
While this is not mandatory in C++, this is one of the several problems that
can't be fixed easily (and safely) in the old C++ parser.  In G++ 3.4.0 the
C++ parser has been rewritten and this rewrite made it far more ISO C++
compliant.


Note You need to log in before you can comment on or make changes to this bug.