This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/5436: explicit instatiation
- From: kunert at physik dot tu-dresden dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 20 Jan 2002 15:25:50 -0000
- Subject: c++/5436: explicit instatiation
- Reply-to: kunert at physik dot tu-dresden dot de
>Number: 5436
>Category: c++
>Synopsis: explicit instatiation
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Sun Jan 20 07:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Thomas Kunert
>Release: 3.0.2, cvs 15.1.02
>Organization:
>Environment:
i586-pc-linux-gnu
>Description:
This code:
template <class T>
class A {
static const int a=17; // #1
A( const A& ); // #2
};
extern template class A<int>;
template class A<int>;
generates the error messages:
test.cc: In instantiation of `A<T>::A(const A<T>&) [with T = int]':
test.cc:8: instantiated from here
test.cc:8: explicit instantiation of `A<T>::A(const A<T>&) [with T = int]' but
no definition available
test.cc: In instantiation of `const int A<int>::a':
test.cc:8: instantiated from here
test.cc:8: explicit instantiation of `A<int>::a' but no definition available
Without the `extern' declaration this error message disappears.
Line #1 is definitely legal and the corresponding
error message is wrong.
I am not sure about #2, but it seems inconsistent that
the legality of this depends on the extern declaration.
Thomas Kunert
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: