[LLVMbugs] [Bug 14223] New: Temporary's destructor not called when exception thrown in a called function when compiled with -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 30 19:45:03 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=14223

             Bug #: 14223
           Summary: Temporary's destructor not called when exception
                    thrown in a called function when compiled with -O2
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: llvm.org at halfy.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 9468
  --> http://llvm.org/bugs/attachment.cgi?id=9468
Test for destructors on temporaries in the presence of exceptions

Attached is a slimmed down case from a production code, where the presence of
an 'if' statement in a function that passes through an exception will not have
the destructors of its temporary variables called.

Note that this only happens when compiling with -O2. Any other optimization
level, including -O3 will give the correct result.

To reproduce:

> clang++ -O2 -o t test.cc
> ./t

Expected output:

  AutoDestroy
  ~AutoDestroy
  Exception: No pointer

Actual output:

  AutoDestroy
  Exception: No pointer


> clang --version
clang version 3.2 (trunk 166893)
Target: x86_64-unknown-linux-gnu
Thread model: posix

-- 
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