// { dg-do run } // { dg-additional-options "-fstrict-aliasing" } template struct Optional { auto is_present() const { const bool &p = inner.present; return p; } auto set_present() { if (not is_present()) inner.present = true; } struct InnerType { bool present = false; char padding[1] = {0}; }; using inner_t = InnerType; inner_t inner = {}; }; template struct Wrapper { auto operator-> () { return value; } WrappedType *value; }; void __attribute__((noipa)) foo(Optional<>& x) {} int main() { Optional<> buf{}; foo(buf); Wrapper> wo = {&buf}; wo->set_present(); auto x = wo->is_present(); if (!x) __builtin_abort (); }