[llvm-bugs] [Bug 40433] New: -Wreturn-stack-address vs -Wreturn-local-addr

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 23 23:31:59 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40433

            Bug ID: 40433
           Summary: -Wreturn-stack-address vs -Wreturn-local-addr
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk, srhines at google.com

While testing out some code in godbolt, I noticed that GCC was flagging this
(contrived, nonsensical) code with -Wreturn-local-addr.

// clang -O2 -std=gnu89 -Wreturn-stack-address
// gcc -O2 -std=gnu89 -Wreturn-local-addr
float* foo() {
    int foo; float* bar = (float*)&foo; return bar;
}

It seems that Clang doesn't warn for this case.  There's a flag in Clang,
`-Wreturn-stack-address`, but it doesn't flag this case.  Maybe 2 action items
here:
1. add alias for -Wreturn-local-addr
2. see if -Wreturn-stack-address is broken for the above case, or what.

-- 
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/20190124/a86c102a/attachment.html>


More information about the llvm-bugs mailing list