strub: enable conditional support
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr93246.C
blob4c5234431755490225609504b516dc190519d0c3
1 // { dg-do run }
2 // { dg-additional-options "-fstrict-aliasing" }
4 template <typename = void> struct Optional {
5   auto is_present() const { const bool &p = inner.present; return p; }
6   auto set_present() { if (not is_present()) inner.present = true; }
7   struct InnerType {
8     bool present = false;
9     char padding[1] = {0};
10   };
11   using inner_t = InnerType;
12   inner_t inner = {};
15 template <typename WrappedType> struct Wrapper {
16   auto operator-> () { return value; }
17   WrappedType *value;
20 void __attribute__((noipa)) foo(Optional<>& x) {}
22 int main()
24   Optional<> buf{};
25   foo(buf);
26   Wrapper<Optional<>> wo = {&buf};
27   wo->set_present();
28   auto x = wo->is_present();
29   if (!x)
30     __builtin_abort ();