Bug 238468 - "syntax error before `>' token" when compiling, using templates
"syntax error before `>' token" when compiling, using templates
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc3 (Show other bugs)
3.7
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-04-30 14:47 EDT by Mike
Modified: 2007-11-16 20:14 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-04-30 15:43:34 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mike 2007-04-30 14:47:39 EDT
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 14:49:38 EDT
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 15:43:34 EDT
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.