[llvm-bugs] [Bug 44916] New: ftrivial-auto-var-init=pattern doesn't initialize locals in switch statement
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 14 11:19:49 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44916
Bug ID: 44916
Summary: ftrivial-auto-var-init=pattern doesn't initialize
locals in switch statement
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: glider at google.com
CC: florian_hahn at apple.com, keescook at chromium.org,
llvm-bugs at lists.llvm.org, llvm-bugzilla at jfbastien.com,
ndesaulniers at google.com, neeilans at live.com,
richard-llvm at metafoo.co.uk, vitalybuka at google.com
In the following case (https://godbolt.org/z/cXxBXz):
#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 (https://godbolt.org/z/CKPQNz)
Clang emits the initialization correctly:
$ ./t 2
v(0x7ffee8020c44): aaaaaaaa
--
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/20200214/a07cfb2c/attachment-0001.html>
More information about the llvm-bugs
mailing list