view gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const24.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 2b5abeee2509
children
line wrap: on
line source

// PR c++/94772
// { dg-do compile { target c++14 } }

struct base
{
  base() = default;

  constexpr base(int) : base{} { }
};

struct foo : base
{
  int x{};

  constexpr foo(int a) : base{a}
  { x = -a; }

  constexpr foo(int a, int b) : foo{a}
  { x += a + b; }
};

int main()
{
  constexpr foo bar{1, 2};
  static_assert(bar.x == 2, "");
}