[Bug c++/59238] New: Dynamic allocating a list-initialized object of a type with private destructor fails.

cassio.neri at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Nov 21 22:00:00 GMT 2013


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

            Bug ID: 59238
           Summary: Dynamic allocating a list-initialized object of a type
                    with private destructor fails.
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cassio.neri at gmail dot com

Consider:

class foo {
  ~foo() {}
};

int main() { 
  new foo;   // OK
  new foo(); // OK
  new foo{}; // error: 'foo::~foo()' is private
}

The last line shouldn't fail to compile since the destructor is not invoked.

FWIW, it compiles fine with clang. It also compiles fine with gcc 4.9.0
20131109 if foo has a user declared default constructor.



More information about the Gcc-bugs mailing list