testsuite: 32 bit AIX 2 byte wchar
[official-gcc.git] / gcc / testsuite / g++.dg / cpp23 / attr-assume10.C
blob475555ac415ddeb989eadf5701e8df3fc1cc66b5
1 // Test that s.i is not modified by the assume.
2 // { dg-do compile { target c++17 } }
4 struct string
6   const char *p;
7   int i;
8   constexpr string (const char *p): p(p), i(0) { }
9   constexpr int length () { ++i; return __builtin_strlen (p); }
12 constexpr int f()
14   string s ("foobar");
15   [[assume (s.length () > 0)]];
16   if (s.i != 0) __builtin_abort();
17   int len = s.length ();
18   if (s.i != 1) __builtin_abort();
19   return len;
22 static_assert (f());