[llvm-bugs] [Bug 39017] New: -Wreturn-stack-address false negative when address is stored in a local variable
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 20 08:04:02 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39017
Bug ID: 39017
Summary: -Wreturn-stack-address false negative when address is
stored in a local variable
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: skvadrik at gmail.com
CC: llvm-bugs at lists.llvm.org
On the following code, I get -Wreturn-stack-address warning only on 'bar', but
not on 'foo' (even with optimization level -O3):
// 1.c
int *foo(void)
{
int n = 123;
int *p;
p = &n;
return p;
}
int *bar(void)
{
int n = 123;
return &n;
}
$ clang -Wreturn-stack-address -c 1.c -O3
1.c:12:11: warning: address of stack memory associated with local variable 'n'
returned [-Wreturn-stack-address]
return &n;
^
1 warning generated.
--
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/20180920/8166982b/attachment.html>
More information about the llvm-bugs
mailing list