[LLVMbugs] [Bug 13505] New: Codegen not generating proper cleanup code for exception handling in destructor of temporary objects.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 1 09:05:33 PDT 2012


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

             Bug #: 13505
           Summary: Codegen not generating proper cleanup code for
                    exception handling in destructor of temporary objects.
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rahulsingh.mnnit at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


extern "C" void abort (); 

int thrown; 

int as;
struct a {
  a () { ++as; }
  ~a () { --as; if (thrown++ == 0) throw 42; }
}; 

int f (a const&) { return 1; } 
int f (a const&, a const&) { return 1; } 

int bs;
int as_sav;
struct b { 
  b (...) { ++bs; }
  ~b ()   { --bs; as_sav = as; }
}; 

bool p;
void g()
{
  if (p) throw 42;
}

int main () { 
  thrown = 0;
  try {
    b tmp(f (a(), a()));

    g();
  }  
  catch (...) {}

  // We throw when the first a is destroyed, which should destroy b before
  // the other a.
  if (as_sav != 1)
    abort ();


} 







For the above code , when observing the .bc file , it is clear that when the
statement  b tmp(f (a(), a())); is getting executed --> at the end of statement
, Clang is destroying the temporaries a(),a() created but since the destructor
of a()  is throwing an exception , Clang should have called b's destructor too
in the cleanup part but in the bytecode , the cleanup part for b is missing so 
for the above test case , in case of exception occuring in the destructors of
the temporaries , b's constructor is not getting called.

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