This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10265: Template failure wrt. 14.5.2 [#2]
- From: gbeauchesne at mandrakesoft dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 29 Mar 2003 11:41:55 -0000
- Subject: c++/10265: Template failure wrt. 14.5.2 [#2]
- Reply-to: gbeauchesne at mandrakesoft dot com
>Number: 10265
>Category: c++
>Synopsis: Template failure wrt. 14.5.2 [#2]
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sat Mar 29 11:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Gwenole Beauchesne
>Release: GNU C++ version 3.2.3 20030329 (prerelease)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
GCC rejects code similar to 14.5.2 [#2] as follows:
[gbeauchesne at thalys vrac]$ g++ member2.C
member2.C:8: template definition of non-template `void A::f()'
member2.C:9: redefinition of `void A::f()'
member2.C:8: `void A::f()' previously defined here
member2.C:9: no `void A::f()' member function declared in class `A'
Reproduced on at least GCC 3.2.X and GCC 3.3 CVS snapshot from 2003/02/05.
>How-To-Repeat:
/* { dg-do compile } */
struct A {
template<class T> void f();
void f();
};
template<class T> void A::f() { }
void A::f() { }
struct B {
template<class T> void f() { }
void f() { }
};
int main()
{
A a;
a.f();
a.f<int>();
B b;
b.f();
b.f<int>();
}
>Fix:
Workaround: define A::f<T>() and A::f() both inline, as exercised in class B.
Both ICC and Comeau C++ compile this correctly. But this is not a fix. ;-)
>Release-Note:
>Audit-Trail:
>Unformatted: