c++/1551: explicit specialization of constructor causes dementia
fsm@robots.ox.ac.uk
fsm@robots.ox.ac.uk
Thu Jan 4 13:06:00 GMT 2001
>Number: 1551
>Category: c++
>Synopsis: explicit specialization of constructor causes dementia
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Jan 04 13:06:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Frederik Schaffalitzky
>Release: CVS gcc version 2.97 20010104 (experimental)
>Organization:
>Environment:
Linux 2.2.17 #3 SMP i686 unknown
>Description:
Explicit specialization of a templated constructor
causes the compiler to reject legal code later. There
is such a specialization in <locale> and hence in
<fstream>.
Symptom:
f.cxx: In constructor `derived<T>::derived() [with T = double]':
f.cxx:27: instantiated from here
f.cxx:11: call of overloaded `base()' is ambiguous
f.cxx:5: candidates are: base<T>::base(unsigned int = 0) [with T = double]
f.cxx:4: base<T>::base() [with T = double]
>How-To-Repeat:
template <typename T>
struct base
{
base();
base(unsigned);
};
template <typename T>
struct derived : base<T>
{
derived() { }
};
#if 1
template <typename V>
struct Y
{
Y(unsigned = 0);
};
template <>
Y<char>::Y(unsigned) { }
#else
# include <locale>
#endif
template struct derived<double>;
>Fix:
No idea. The bug is not expressed if any of the following
changes is made:
1. change the argument type of base::base from unsigned
to int.
2. remove the default argument to Y::Y.
3. move the specialization to the top of the file.
4. another class is derived from base<double> before the
explicit specialization.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list