aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8.1/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable.C
blob: 73a4d1bac746ce68559f7f321384bfe39362901f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// { dg-do run }
// { dg-options "-std=c++0x" }
#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;
}