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

            Bug ID: 106212
           Summary: Code becomes non-constexpr with _GLIBCXX_DEBUG
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fiesh at zefix dot tv
  Target Milestone: ---

Consider the following C++20 code:

#include <array>
struct P {
  constexpr P(int i) : e{i} {}
  auto operator<=>(P const &) const = default;
  std::array<int, 1> e;
};
constexpr auto operator-(P lhs, P) { return lhs; }
constexpr P p{1}, q{0};
static_assert(p - q != 0);


It behaves as follows:
* g++ compiles it successfully
* g++ with -D_GLIBCXX_DEBUG does not compile it
* clang++ compiles it successfully
* clang++ -D_GLIBCXX_DEBUG compiles it successfully

See also https://godbolt.org/z/ve19v1re9

Reply via email to