aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval-prop4.C
blob: 3a2e09b17b0807fd422da36ad400f77ae401fd8d (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
29
30
// P2564R3
// { dg-do compile { target c++20 } }
// From clang's cxx2b-consteval-propagate.cpp.  This test ICEd when I worked on
// P2564.

consteval int f (int);

struct S {
  int a = 0;
  int b = f (a);
};

constexpr bool
g (auto i)
{
  S s{i};
  return s.b == 2 *i;
}

consteval int
f (int i)
{
  return 2 * i;
}

void
test ()
{
  static_assert(g(42));
}