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

            Bug ID: 98712
           Summary: Incorrect defaulted operator== at compile time and
                    runtime when declared constexpr and inheriting
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan_greenblatt at brown dot edu
  Target Milestone: ---

```
struct IntHolder {
  int v;
  bool operator==(const IntHolder &) const = default;
};

struct Inherits : IntHolder {
  // without constexpr here the issue goes away...
  constexpr bool operator==(const Inherits &) const = default;
};

#if 0
static_assert(Inherits{1} != Inherits{2});
#else
#include <iostream>

int main() {
  // should output true...
  volatile int l = 1;
  std::cout << std::boolalpha << (Inherits{l} != Inherits{2}) << std::endl;
}
#endif
```
https://godbolt.org/z/145dbq

Reply via email to