Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/constexpr-nonlit15.C

raw
1 // PR c++/106649
2 // P2448 - Relaxing some constexpr restrictions
3 // { dg-do compile { target c++23 } }
4 // { dg-options "-Winvalid-constexpr" }
5 // A copy/move assignment operator for a class X that is defaulted and
6 // not defined as deleted is implicitly defined when it is odr-used,
7 // when it is needed for constant evaluation, or when it is explicitly
8 // defaulted after its first declaration.
9 // The implicitly-defined copy/move assignment operator is constexpr.
10
11 struct S {
12 constexpr S() {}
13 S& operator=(const S&) = default;
14 S& operator=(S&&) = default;
15 };
16
17 struct U {
18 constexpr U& operator=(const U&) = default;
19 constexpr U& operator=(U&&) = default;
20 };
21
22 constexpr void
23 g ()
24 {
25 S a;
26 S b;
27 b = a;
28 b = S{};
29
30 U u, v;
31 u = v;
32 u = U{};
33 }
34
35 static_assert ((g(), true), "");