[llvm-bugs] [Bug 42778] New: Cannot aggregate initialize with C++17 *this lambda capture

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 26 08:06:02 PDT 2019


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

            Bug ID: 42778
           Summary: Cannot aggregate initialize with C++17 *this lambda
                    capture
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: romain.geissler at amadeus.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Hi,

The following snippet triggers a compiler error with -std=gnu++17:

<<END_OF_FILE
#include <functional>

struct A
{
    std::function<void()> function;

    void f() {};
};

struct B
{
    void f()
    {
        A{[*this](){}}.f();
    }
};
END_OF_FILE

It fails with:

<source>:14:18: warning: use of GNU 'missing =' extension in designator
[-Wgnu-designator]

        A{[*this](){}}.f();

                 ^

                 = 

<source>:14:19: error: expected expression

        A{[*this](){}}.f();

                  ^

<source>:14:12: error: integral constant expression must have integral or
unscoped enumeration type, not 'B'

        A{[*this](){}}.f();

           ^~~~~

1 warning and 2 errors generated.

Compiler returned: 1


tested with clang 8, 9 and current HEAD: https://godbolt.org/z/gVhxD3 Gcc 9 is
happy with that.

-- 
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/20190726/017bd374/attachment.html>


More information about the llvm-bugs mailing list