summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/stmtexpr8.C
blob: 8e5d0ddcba25983516f0f54fd128ed49c2fa5fa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// PR c++/27115

// { dg-do run }
// { dg-options "" }

struct A
{
  int i;
  A (int j) : i(j) {}
  A (const A &j) : i(j.i) {}
  A& operator= (const A &j) { i = j.i; return *this; }
};

A foo(int j)
{
  return ({ j ? A(1) : A(0); });
}

int main()
{
  return foo(1).i-1;
}

void foo2()
{
  A b = ({ A a(1); a; });
}