[LLVMbugs] [Bug 10870] New: buggy behaviour when exception is thrown from the constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 6 08:15:41 PDT 2011


           Summary: buggy behaviour when exception is thrown from the
           Product: clang
           Version: 2.9
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: adriano.mitre at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

The attached example demonstrates what seems to be a bug in clang when an
exception is thrown from the constructor. Although the behaviour is different
whether the construction/allocation is static or dynamic, it is wrong in both

  $ make CXX=g++ # default
  $ /ctorexcept static 1234
  instances: 0
  $ /ctorexcept dynamic 1234
  instances: 0
  $ make CXX=clang++
  $ /ctorexcept static 1234
  instances: 10
  $ /ctorexcept dynamic 1234
  # segmentation fault!
  # according to valgrind it was an "Invalid free() / delete / delete[]"

If the destructor is not defined, which may be achieved compiling with
no segmentation fault ocurrs in the dynamic case, making its behaviour seemly
identical to the static case.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list