https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122072

            Bug ID: 122072
           Summary: bad diagnostic for non-local lambda with a
                    simple-capture
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ing.russomauro at gmail dot com
  Target Milestone: ---

The following code, compiled with C++11 or C++23 with gcc 15.2 :

( https://godbolt.org/z/W6374PbYn )

int x;

auto f = [x]{};

int main(){}


badly provides priority to the warning related to capturing a non-automatic
variable, instead of the fact that a non-local lambda cannot have
capture-default or simple-captures.

For example:

auto g = [=]{};

well triggers the expected error.

Really, as far as I know, even the warning above should be an error.

Reply via email to