Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/torture/pr93246.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
line wrap: on
line source
// { dg-do run } // { dg-additional-options "-fstrict-aliasing" } template <typename = void> 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 <typename WrappedType> struct Wrapper { auto operator-> () { return value; } WrappedType *value; }; void __attribute__((noipa)) foo(Optional<>& x) {} int main() { Optional<> buf{}; foo(buf); Wrapper<Optional<>> wo = {&buf}; wo->set_present(); auto x = wo->is_present(); if (!x) __builtin_abort (); }