[llvm-bugs] [Bug 44150] New: [10.master regression] false positive warning -Wreturn-stack-address

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 26 07:03:15 PST 2019


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

            Bug ID: 44150
           Summary: [10.master regression] false positive warning
                    -Wreturn-stack-address
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kyrylo.bohdanenko at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

I have noticed this with clang master (llvm 10) (built from
3b901ce36755bf67c62d9ba5866ad9e0ab9f546d). The following snippet produces false
positive warning:

  #include <vector>

  std::vector<int>::const_iterator test(const std::vector<int>& data) {
    std::vector iters{data.begin()};
    return iters.front();
  }

Compiler output:

prog.cc:5:10: warning: address of stack memory associated with local variable
'iters' returned [-Wreturn-stack-address]
  return iters.front();
         ^~~~~
1 warning generated.

This is clearly incorrect, because function is supposed to return a (copy of)
iterator to the argument vector ref.

Earlier release versions of clang do not produce such warning.

P.S. This bug does not duplicate #21218, since the latter was reported much
earlier and this only affects current master.

-- 
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/20191126/17d5bb88/attachment.html>


More information about the llvm-bugs mailing list