This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/345: forward declaration in template classes not working correctly
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/345: forward declaration in template classes not working correctly
- From: ssm at antrim dot com
- Date: 23 Jun 2000 17:08:39 -0000
- Reply-To: ssm at antrim dot com
- Resent-Cc: gcc-prs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, ssm@antrim.com
>Number: 345
>Category: c++
>Synopsis: forward declaration in template classes not working correctly
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jun 23 10:15:59 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: S. Mitra
>Release: gcc 2.95.2
>Organization:
>Environment:
GNU C++ version 2.95.2 19991024 (release) (sparc-sun-solaris2.7) compiled by GNU C version 2.7.2.f.1.
>Description:
Looks like a in-place forward class declaration doesn't
work inside a parameter declaration of a template class
member function. (The testcase makes a lot more sense.)
This works in gcc 2.7.2.
A very simple test case follows:
/***********************
g++ 2.7.2 compiles (with -c) fine whether or not FDECL is defined.
g++ 2.95.2 compiles fine only if FDECL is defined.
If FDECL is not defined, it produces:
x.C:18: prototype for `void Table<size,J>::foo(int, B *)' does not match any in
class `Table<size,J>'
x.C:13: candidate is: void Table<size,J>::foo(int, B *)
x.C: In method `void Table<size,J>::foo(int, B *)':
x.C:18: template definition of non-template `void Table<size,J>::foo(int, B *)'
************************/
class A
{
};
#ifdef FDECL
class B;
#endif
template<int size, class J>
class Table
{
public:
void foo(int a, class B* b);
};
template<int size, class J>
void Table<size, J>::foo(int a, class B* b)
{
}
>How-To-Repeat:
Run 'g++ -c' on the given testcase.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: