[LLVMbugs] [Bug 21011] New: [C++11] An assignment of a lambda expression to a pointer to function ignores exception specification.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Sep 20 05:14:01 PDT 2014


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

            Bug ID: 21011
           Summary: [C++11] An assignment of a lambda expression to a
                    pointer to function ignores exception specification.
           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

A sample code below should cause a compilation error but it is compiled
successfully by clang.
=================================
int main()
{
    void(*fp)() noexcept = []{};
    fp();
}
=================================
cf. http://melpon.org/wandbox/permlink/kS5AxGICzzglWBTW

According to C++11 standard [expr.prim.lambda] 5.1.2/5, "[]{}" has a conversion
function to pointer to function "void(*)()".
C++11 standard [except.spec] 15.4/5 also says that "the target entity shall
allow at least the exceptions allowed by the source value in the assignment or
initialization."

So, I think that the sample code above is ill-formed.

I don't know whether a sample code below should be compiled successfully or not
because any struct cannot have a conversion function to pointer to function
"void(*)() noexcept".
=================================
int main()
{
    void(*fp)() noexcept = []() noexcept {};
    fp();
}
=================================

-- 
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/20140920/5f333218/attachment.html>


More information about the llvm-bugs mailing list