[LLVMbugs] [Bug 13484] New: Non-capturing lambas should be a constant expression

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 30 16:22:00 PDT 2012


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

             Bug #: 13484
           Summary: Non-capturing lambas should be a constant expression
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: pfultz2 at yahoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Although the standard doesn't specify if lambda expressions are literal types,
gcc does allow it, and this could be useful for when you want to have a lambda
at class scope. 

Here is an example code:

struct A
{
    static constexpr auto F = [](){};
};

int main()
{
    A::F();
    return 0;
}

Clang produces this error:

error: constexpr variable 'F' must be initialized by a constant
      expression
    static constexpr auto F = [](){};
                              ^~~~~~

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list