You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clang/test/SemaCXX/cxx2c-constexpr-placement-new.cpp
+39Lines changed: 39 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -114,3 +114,42 @@ constexpr bool bleh() {
114
114
}
115
115
static_assert(bleh()); // expected-error {{not an integral constant expression}} \
116
116
// expected-note {{in call to 'bleh()'}}
117
+
118
+
constexprintmodify_const_variable() {
119
+
constint a = 10;
120
+
new ((int *)&a) int(12); // expected-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
121
+
return a;
122
+
}
123
+
static_assert(modify_const_variable()); // expected-error {{not an integral constant expression}} \
124
+
// expected-note {{in call to}}
125
+
126
+
typedefconstint T0;
127
+
typedef T0 T1;
128
+
constexpr T1 modify_const_variable_td() {
129
+
T1 a = 10;
130
+
new ((int *)&a) int(12); // expected-note {{modification of object of const-qualified type 'T1' (aka 'const int') is not allowed in a constant expression}}
131
+
return a;
132
+
}
133
+
static_assert(modify_const_variable_td()); // expected-error {{not an integral constant expression}} \
134
+
// expected-note {{in call to}}
135
+
136
+
template<typename T>
137
+
constexpr T modify_const_variable_tmpl() {
138
+
T a = 10;
139
+
new ((int *)&a) int(12); // expected-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
140
+
return a;
141
+
}
142
+
static_assert(modify_const_variable_tmpl<constint>()); // expected-error {{not an integral constant expression}} \
0 commit comments