[llvm-bugs] [Bug 50003] New: Warns about lambda function based on the return type that is not what inferred return type is

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 16 12:04:51 PDT 2021


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

            Bug ID: 50003
           Summary: Warns about lambda function based on the return type
                    that is not what inferred return type is
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yuri at tsoft.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

Created attachment 24762
  --> https://bugs.llvm.org/attachment.cgi?id=24762&action=edit
testcase-clang-bug-warns-about-fantom-return.cpp

The lambda function is written like it returns char* but the inferred return
type is std::string.

clang-10 warns:
> testcase-clang-bug-warns-about-fantom-return.cpp:14:11: warning: address of stack memory associated with local variable 't' returned [-Wreturn-stack-address]
>                         return t;
>                                ^
> 1 warning generated.

as if this function returns char*, but the actual correct inferred return type
is std::string and there should be no warning.

-- 
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/20210416/df352025/attachment.html>


More information about the llvm-bugs mailing list