view gcc/testsuite/g++.dg/opt/pr93210.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

// PR tree-optimization/93210
// { dg-do compile { target c++11 } }
// { dg-options "-O2 -fdump-tree-optimized" }
// { dg-final { scan-tree-dump-not "static_member\.d" "optimized" } }

union U { struct { unsigned int a, b; } c; unsigned long long d; };

inline
bool operator == (U const &x, U const &y) noexcept
{
  return x.d == y.d;
};

struct S
{
  static constexpr U static_member = { { 13, 42 } };
  bool foo (U const &y) const noexcept;
  bool bar (U const &y) const noexcept;
};

#if __cpp_inline_variables < 201606L
constexpr U S::static_member;
#endif

#if __SIZEOF_INT__ * 2 == __SIZEOF_LONG_LONG__
bool
S::foo (U const &y) const noexcept
{
  return static_member == y;
}

bool
S::bar (U const &y) const noexcept
{
  return U (static_member) == y;
}
#endif