This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49470] New: no matching constructor for initialization errors not detected in g++
- From: "howarth at nitro dot med.uc.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 20 Jun 2011 03:06:06 +0000
- Subject: [Bug c++/49470] New: no matching constructor for initialization errors not detected in g++
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49470
Summary: no matching constructor for initialization errors not
detected in g++
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: howarth@nitro.med.uc.edu
Currently g++ doesn't warn or error on invalid code such as...
template <class T> class Array1D {
Array1D(int n, T *a);
};
template<typename T>
struct A {
Array1D<int> x;
A() : x(1, (const int*)0) {}
};
for which clang++ produces the error...
[MacPro:~] howarth% clang++ -c invalid.cc
invalid.cc:7:9: error: no matching constructor for initialization of
'Array1D<int>'
A() : x(1, (const int*)0) {}
^ ~~~~~~~~~~~~~~~~
invalid.cc:2:3: note: candidate constructor not viable: 2nd argument ('const
int *') would lose const qualifier
Array1D(int n, T *a);
^
invalid.cc:1:26: note: candidate constructor (the implicit copy constructor)
not viable: requires 1 argument, but 2 were provided
template <class T> class Array1D {
^
1 error generated.