[Bug c++/21363] no compilation error for inheriting Base class with private constructor when the constructor for Derived Class is compiler generated

2005-05-04 Thread hingwah at hingwah dot net

--- Additional Comments From hingwah at hingwah dot net  2005-05-05 04:58 
---
i don't think compiler generated constructor should have the privilege to
invoke constructor of parent class which is private.

-- 


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


[Bug c++/21363] New: no compilation error for inheriting Base class with private constructor when the constructor for Derived Class is compiler generated

2005-05-03 Thread hingwah at hingwah dot net
The following code  generate a compilation error:
class Foo {
private:
  Foo() { }
  
};

class Bar : public Foo
{
public:
   Bar() {}
};
int main()
{
  return 0;

}

however,commenting out Bar(){}  (i.e. let the compiler generate one for me),do
not cause any compilation error.
the same case for virtual base constructor(in which I discover it when reading
C++ faq 23.9)

class FooBase 
{
  friend class Foo;
private:
  FooBase();

};
class Foo : virtual private FooBase
{
public:
  Foo() { }
  
};

class Bar : private virtual Foo
{
public:
  Bar() {} //no error if comment it out
  
  

};
int main()
{
  return 0;

}

test on gcc 3.3 and gcc 3.4 in debian:
g++-3.4 (GCC) 3.4.4 20050314 (prerelease) (Debian 3.4.3-12)
g++-3.3 (GCC) 3.3.5 (Debian 1:3.3.5-12)

-- 
   Summary: no compilation error for inheriting Base class with
private constructor when the constructor for Derived
Class is compiler generated
   Product: gcc
   Version: 3.3.5
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hingwah at hingwah dot net
CC: gcc-bugs at gcc dot gnu dot org


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