[Bug c++/50034] New: Overload selection failure within class template
crowl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 9 21:32:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50034
Bug #: 50034
Summary: Overload selection failure within class template
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: crowl@gcc.gnu.org
The following code fails to compile with
g++ (GCC) 4.7.0 20110809 (experimental) [trunk revision 177606]
template <typename From, typename To>
class implicit {
private:
static From from_type();
static char selector(To);
static char (&selector(...))[2];
public:
static const bool value = sizeof(selector(implicit::from_type())) == 1;
};
template <typename From, typename To>
const bool implicit<From, To>::value;
class abstract {
virtual void pure() = 0;
abstract(const abstract&);
};
int main() {
return implicit<const abstract&, long long int>::value;
}
# Note that I am not using C++0x.
g++ -c implicit.cc
implicit.cc: In instantiation of 'const bool implicit<const abstract&,
long long int>::value':
implicit.cc:20:54: required from here
implicit.cc:16:3: error: 'abstract::abstract(const abstract&)' is private
implicit.cc:8:72: error: within this context
implicit.cc:8:72: error: cannot allocate an object of abstract type 'abstract'
implicit.cc:14:7: note: because the following virtual functions are
pure within 'abstract':
implicit.cc:15:16: note: virtual void abstract::pure()
More information about the Gcc-bugs
mailing list