<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW " title="NEW --- - Clang exception handling: wrong IR generation - no cleanup for array of memcpy-able objects in struct" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24005&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=xpzOqoX08smqx-lxA_3f3Gq2EFcW78YFPuSlZv1fi0Y&s=NVBxHBsm3BcrkTOS6qwEciCeds9rMRYpLucQO8xqJDM&e=">24005</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang exception handling: wrong IR generation - no cleanup for array of memcpy-able objects in struct
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>d.zobnin.bugzilla@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>