Bug 238468
Summary: | "syntax error before `>' token" when compiling, using templates | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 3 | Reporter: | Mike <mrkfact> |
Component: | gcc3 | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED WONTFIX | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 3.7 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2007-04-30 19:43:34 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Mike
2007-04-30 18:47:39 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; } 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. |