Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Enhance "returning address of local var" checker #37851

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR38878
Status NEW
Importance P enhancement
Reported by David Bolvansky (david.bolvansky@gmail.com)
Reported on 2018-09-09 09:57:18 -0700
Last modified on 2018-09-09 09:58:39 -0700
Version trunk
Hardware PC Linux
CC dgregor@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
struct S&& po() {
    struct S tmp;
    return std::move(tmp);
}

No warning from Clang.

GCC warns:
<source>: In function 'S&& po()':
<source>:14:23: warning: function returns address of local variable [-Wreturn-
local-addr]
14 |     return std::move(tmp);
   |                       ^
<source>:13:14: note: declared here
13 |     struct S tmp;
Quuxplusone commented 6 years ago