This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/55635] New: Deallocation function ("operator delete") not called when destructor throws exception


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

             Bug #: 55635
           Summary: Deallocation function ("operator delete") not called
                    when destructor throws exception
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: joedoefawnbuck@googlemail.com


According to C++11, 5.3.5/7, the deallocation function of a dynamically
allocated object must be called upon a `delete` expression regardless of
whether the destructor exits with an exception or not.

However, when I run the following code through valgrind, it says that I have
one still-reachable block:

struct Foo { ~Foo() { throw 0; } };

int main()
{
    auto p = new Foo;
    try { delete p; }
    catch (...) { }
}

Am I reading the standard right that the memory should be deallocated
regardless?

(SO discussion: http://stackoverflow.com/q/13792981/596781)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]