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: unassignedb...@nondot.org
Reporter: skvad...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs