Debian Codegraph @

gcc/testsuite/g++.dg/opt/is_constant_evaluated4.C

raw
1 // PR c++/114970
2 // { dg-do compile { target c++17 } }
3 // { dg-additional-options "-O -Wunused-value" }
4
5 struct sv
6 {
7 const char* str;
8 unsigned len;
9
10 constexpr sv(const char *p): str(p), len(0)
11 {
12 if (__builtin_is_constant_evaluated ()) { len = 42; }
13 }
14 };
15
16 int main()
17 {
18 sv s ("foo");
19 return s.len;
20 }