This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13270] New: Failed compile of template function in template class called from another template
- From: "Mark dot Hodson at dsto dot defence dot gov dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2003 12:11:23 -0000
- Subject: [Bug c++/13270] New: Failed compile of template function in template class called from another template
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
G'day everyone, this bug is in v3.3.3 and v3.4 (20031126), though the error
message it emits differs for the two. My guess is you are most interested in
the result for v3.4, thus I have logged this bug against that version.
It appears not to be related to any existing template bugs, though without good
knowledge of the innards of GCC I may be wrong. Furthermore, my guess for the
component would either be c++ or libstdc++, but I have no idea which.
The short of it is that GCC accepts the source with VIA_FUNCTION_TEMPLATE and
VIA_CLASS_TEMPLATE defines commented out - in this case the only Test template
instantiation is from main(), which works fine. With either macro uncommented,
effectively the same code as is in main() is reproduced inside another template
(either class or function), and an instance of this template created in main
(). Here GCC fails to compile with a rather uninteresting low-level-parse
style error. The test is as concise as I could get it, hope it helps.
Test system:
RedHat Linux 9, i386 build of GCC 3.3.3 GNU release packages (RPMs).
RedHat Linux 9, i686 bootstrap build of GCC 3.4 snapshot 20031126.
Test invocation:
g++ -g -Wall -c template_type_test.cpp -o template_type_test.o
Test output (v3.4):
template_type_test.cpp: In function `void TestSetF(const Allocator&)':
template_type_test.cpp:22: error: expected primary-expression
template_type_test.cpp: In static member function `static void
TestSetC<Allocator>::DoIt(const Allocator&)':
template_type_test.cpp:36: error: expected primary-expression
Test output (v3.3.3):
template_type_test.cpp: In function `void TestSetF(const Allocator&)':
template_type_test.cpp:22: error: parse error before `>' token
template_type_test.cpp: In static member function `static void
TestSetC<Allocator>::DoIt(const Allocator&)':
template_type_test.cpp:36: error: parse error before `;' token
This compiles successfully under both MS VC7.1 (.NET 2003) and Borland C++
Builder 6. I will attach the source once I figure out how to use Bugzilla :).
--
Summary: Failed compile of template function in template class
called from another template
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Mark dot Hodson at dsto dot defence dot gov dot au
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13270