view gcc/testsuite/g++.dg/cpp1z/aggr-base1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run { target c++17 } }

struct base1 { int b1, b2 = 42; };
struct base2 {
  base2() {
    b3 = 42;
  }
  int b3;
};
struct derived : base1, base2 {
  int d;
};

derived d1{{1, 2}, {}, 4};
derived d2{{}, {}, 4};

#define assert(X) do { if (!(X)) __builtin_abort(); } while(0)
int main()
{
  assert (d1.b1 == 1 && d1.b2 == 2 && d1.b3 == 42 && d1.d == 4);
  assert (d2.b1 == 0 && d2.b2 == 42 && d2.b3 == 42 && d2.d == 4);
}