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: unassignedclangb...@nondot.org
          Reporter: romain.geiss...@amadeus.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to