<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 --- - [seh] Returnig non-const value from __finally causes verifier error"
href="https://llvm.org/bugs/show_bug.cgi?id=27378">27378</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[seh] Returnig non-const value from __finally causes verifier error
</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>LLVM Codegen
</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>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ clang -v
clang version 3.9.0 (cfe/trunk 266451)
Target: x86_64-pc-windows-msvc
Thread model: posix
-----------------------------------------------
Consider the following code:
---------------------1.cpp---------------------
int f() {
int x;
__try {
}
__finally {
return x;
}
}
-----------------------------------------------
$ clang -c 1.cpp
-------------------Output----------------------
1.cpp:6:5: warning: jump out of __finally block has undefined behavior
[-Wjump-seh-finally]
return x;
^
Instruction referencing instruction not embedded in a basic block!
%x = bitcast i8* %0 to i32*
<badref> = load i32, i32* %x, align 4
fatal error: error in backend: Broken function found, compilation aborted!
When a function call is used in return, the error message is different:
---------------------1.cpp---------------------
int g() { return 5; }
int f() {
int x;
__try {
}
__finally {
return g();
}
}
-----------------------------------------------
$ clang -c 1.cpp
-------------------Output----------------------
1.cpp:9:5: warning: jump out of __finally block has undefined behavior
[-Wjump-seh-finally]
return g();
^
Global is referenced by parentless instruction!
i32 ()* @"\01?g@@YAHXZ"
; ModuleID = '1.cpp'
%call = call i32 @"\01?g@@YAHXZ"()
fatal error: error in backend: Broken module found, compilation aborted!
If constant value is returned, Clang doesn't emit errors:
---------------------1.cpp---------------------
int f() {
const int x = 0;
__try {
}
__finally {
return x + 10;
}
}
-----------------------------------------------
$ clang -c 1.cpp
Emits only warning.</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>