http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54574

             Bug #: 54574
           Summary: G++ accepts parameters with wrong types in parent
                    constructor
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: car...@google.com


When compiling the following source code,

class C
{
public:
  C (int* Items[]);
};

template<class T> class A : public C
{
public:
  A (int Items[])
    : C (Items) {        // C is called with wrong parameter type, expects
int**
  };
};

int i[5];
A<int> yyy(i);

Trunk g++ silently accepts it. While clang produces following error message:


cursesm.ii:11:7: error: no matching constructor for initialization of 'C'
    : C (Items) {
      ^  ~~~~~
cursesm.ii:4:3: note: candidate constructor not viable: no known conversion
from 'int *' to 'int **' for 1st argument; take the address of the argument
with &
  C (int* Items[]);
  ^
cursesm.ii:1:7: note: candidate constructor (the implicit copy constructor) not
viable: no known conversion from 'int *' to 'const C' for 1st argument;
class C
      ^
cursesm.ii:10:3: error: constructor for 'A<int>' must explicitly initialize the
base class 'C' which does not have a default constructor
  A (int Items[])
  ^
cursesm.ii:16:8: note: in instantiation of member function 'A<int>::A'
requested here
A<int> yyy(i);
       ^
cursesm.ii:1:7: note: 'C' declared here
class C
      ^

It also impacts branches 4.6 and 4.7.

Reply via email to