comparison gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const2.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 // PR c++/91264
2 // { dg-do compile { target c++14 } }
3
4 struct X {
5 int j;
6 constexpr X() : j(0) { }
7 };
8
9 struct Y {
10 X x;
11 constexpr Y() : x{} { }
12 };
13
14 constexpr void
15 g ()
16 {
17 const Y y; // { dg-message "originally declared" }
18 Y *p = const_cast<Y *>(&y);
19 p->x.j = 99; // { dg-error "modifying a const object" }
20 }
21
22 static_assert((g() , 1), ""); // { dg-error "non-constant condition" }
23 // { dg-message "in 'constexpr' expansion of" "" { target *-*-* } .-1 }