https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93246

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
          Component|sanitizer                   |middle-end
      Known to work|10.0, 8.3.0                 |6.5.0
   Target Milestone|9.3                         |8.4
            Summary|[9/10 Regression]           |[8/9/10 Regression]
                   |Unexpected program behavior |Unexpected program behavior
                   |when -fsanitize=address and |when -fsanitize=address and
                   |-O2/O3 used                 |-O2/O3 used
      Known to fail|                            |7.5.0

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So -fno-ipa-sra "fixes" things for GCC 9.  The following makes the testcase
resilent against that and also shows GCC 10 is broken:

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;
  //InnerType inner = {}; // this works as expected!
  inner_t inner = {}; // this doesn't!
};

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 ();
}


putting some __asm__ volatile ("" : : : "memory"); into foo() and adding
noinline/noclone makes it also fail with GCC 7.5 but not GCC 6.

Reply via email to