[LLVMbugs] [Bug 24005] New: Clang exception handling: wrong IR generation - no cleanup for array of memcpy-able objects in struct
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jul 1 07:52:06 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24005
Bug ID: 24005
Summary: Clang exception handling: wrong IR generation - no
cleanup for array of memcpy-able objects in struct
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: d.zobnin.bugzilla at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
When compiling the following test:
struct A {
int x;
A() { x = 10; }
~A () { x = 20; }
};
struct B {
B () {}
B (const B &) {
throw 1;
}
};
struct C {
A a[2];
B b;
};
int main () {
try {
C c1;
C c2(c1);
}
catch (...) {
return 1;
}
return 0;
}
$ clang -cc1 -fexceptions -fcxx-exceptions -O0 test.cpp -emit-llvm -o test.ll
Clang generates the following IR for the copy-ctor of C:
entry:
%this.addr = alloca %struct.C*, align 8
%.addr = alloca %struct.C*, align 8
store %struct.C* %this, %struct.C** %this.addr, align 8
store %struct.C* %0, %struct.C** %.addr, align 8
%this1 = load %struct.C*, %struct.C** %this.addr
%a = getelementptr inbounds %struct.C, %struct.C* %this1, i32 0, i32 0
%1 = load %struct.C*, %struct.C** %.addr
%a2 = getelementptr inbounds %struct.C, %struct.C* %1, i32 0, i32 0
%2 = bitcast [2 x %struct.A]* %a to i8*
%3 = bitcast [2 x %struct.A]* %a2 to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %3, i64 8, i32 4, i1 false)
%b = getelementptr inbounds %struct.C, %struct.C* %this1, i32 0, i32 1
%4 = load %struct.C*, %struct.C** %.addr, align 8
%b3 = getelementptr inbounds %struct.C, %struct.C* %4, i32 0, i32 1
call void @_ZN1BC1ERKS_(%struct.B* %b, %struct.B* dereferenceable(1) %b3)
ret void
So the copy-ctor of struct B is called, not invoked, and there are no landing
pads and cleanups for previously constructed objects, no calls for ~A().
Denis Zobnin
=============
Software Engineer
Intel Compiler Team
Intel
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150701/9751fc56/attachment.html>
More information about the llvm-bugs
mailing list