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

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Some examples of using the leaky abstractions, adapted from the video:

int main ()
{
  auto lambda = [val = 2](){ return val; };

  //lambda.__val = 4;

  return lambda();
}

On uncommenting the assignment, GCC generates a return of 4, rather than 2.


int test ()
{
  int arr[] = {1, 2, 3, 4, 5};
  int sum = 0;
  for (const auto v: arr) {
    sum += v;
    //__for_begin = __for_end;
  }
  return sum;
}

On uncommenting the assignment, GCC generates an infinite loop.

Reply via email to