[LLVMbugs] [Bug 18507] New: lambda expression that has an inconsistent return-type should be detected

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 16 07:18:09 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18507

            Bug ID: 18507
           Summary: lambda expression that has an inconsistent return-type
                    should be detected
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kariya_mitsuru at hotmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I think that sample code below should cause compilation error because the
lambda function has a return-type "void" but it returns an "int".

#include <iostream>

int main()
{
    auto G = [] {
        static int x = 0;
        return ++x;
    };
    std::cout << G() << std::endl;
}

According to C++11 starndard 5.1.2 p4, if lambda-expression does not include a
trailing-return-type and coumpound-statement has any statement other than
return statement, its return type is void.

-- 
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/20140116/7640a2fe/attachment.html>


More information about the llvm-bugs mailing list