This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/1652: CVS20010114 tries to instantiate wrong template
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1652: CVS20010114 tries to instantiate wrong template
- From: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
- Date: 15 Jan 2001 08:52:26 -0000
- Reply-To: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
>Number: 1652
>Category: c++
>Synopsis: CVS20010114 tries to instantiate wrong template
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Jan 15 00:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
CVS of 20010114, on Linux
>Description:
In the following case, gcc tries to instantiate the wrong
template function (there is a specialization, so it shouldn't
even try to look at the general template):
deal.II/deal.II> cat tt.cc
struct X { X(int); };
template <int dim> struct PtrDef { typedef X T; };
template <> struct PtrDef<2> { typedef void* T; };
template <int dim> struct Y {
typename PtrDef<dim>::T f (const unsigned int = 0) const;
};
template <int dim>
typename PtrDef<dim>::T Y<dim>::f (const unsigned int) const { return X(3); };
template <>
PtrDef<2>::T Y<2> ::f (const unsigned int) const { return 0; };
template struct Y<2>;
deal.II/deal.II> c++ -W -Wall -c tt.cc -o /dev/null
tt.cc: In member function `typename PtrDef<dim>::T Y<dim>::f(unsigned int)
const [with int dim = 2]':
tt.cc:15: instantiated from here
tt.cc:11: cannot convert `X' to `void*' in return
Note that the problem goes away if either
- I remove the 'const'ness of the function
- I remove the default argument.
Regards
Wolfgang
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: