Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/constexpr-111284.C

raw
1 // PR c++/111284
2 // { dg-do compile { target c++17 } }
3
4 struct S {
5 S () = default;
6 constexpr S (const S &) noexcept : s{this} {}
7 constexpr S & operator= (const S &) noexcept { return *this; }
8 constexpr bool foo () const noexcept { return s == this; }
9 S *s = this;
10 };
11
12 constexpr bool
13 bar (S x) noexcept
14 {
15 return x.foo ();
16 }
17
18 static_assert (bar (S {}), "");
19 static_assert ([] (S x) { return x.foo (); } (S {}), "");