view gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run { target c++11 } }
#include <cassert>

int main() {
  int i = 1;
  const char* s1 = "hello";
  const char* s2 = s1;
  [i, s2] () mutable -> void { i = 2; s2 = "world"; } ();
  //[i, s2] () -> void { i = 2; s2 = "world"; } (); // { dg-error: "assignment of data-member in read-only structure" }
  assert(i == 1);
  assert(s1 == s2);

  return 0;
}