<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - ftrivial-auto-var-init=pattern doesn't initialize locals in switch statement"
href="https://bugs.llvm.org/show_bug.cgi?id=44916">44916</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ftrivial-auto-var-init=pattern doesn't initialize locals in switch statement
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>glider@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>florian_hahn@apple.com, keescook@chromium.org, llvm-bugs@lists.llvm.org, llvm-bugzilla@jfbastien.com, ndesaulniers@google.com, neeilans@live.com, richard-llvm@metafoo.co.uk, vitalybuka@google.com
</td>
</tr></table>
<p>
<div>
<pre>In the following case (<a href="https://godbolt.org/z/cXxBXz">https://godbolt.org/z/cXxBXz</a>):
#include <stdio.h>
int main(int argc, char **argv) {
switch (argc) {
int v;
case 1:
v = 2;
default:
printf("v(%p): %x\n", &v, v);
}
return 0;
}
Clang doesn't force-initialize |v| when run with
-ftrivial-auto-var-init=pattern:
$ ./t 2
v(0x7ffcab198224): 7ffc
In the case |v| is moved outside the switch (<a href="https://godbolt.org/z/CKPQNz">https://godbolt.org/z/CKPQNz</a>)
Clang emits the initialization correctly:
$ ./t 2
v(0x7ffee8020c44): aaaaaaaa</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>