| 1 |
// RUN: %clang_cc1 %s -std=c++23 -verify -Wfloat-equal |
| 2 |
|
| 3 |
struct Foo { |
| 4 |
float val; |
| 5 |
bool operator==(const Foo &) const; |
| 6 |
friend bool operator==(const Foo &, const Foo &); |
| 7 |
friend bool operator==(Foo, Foo ); |
| 8 |
}; |
| 9 |
|
| 10 |
// Declare the defaulted comparison function as a member function. |
| 11 |
bool Foo::operator==(const Foo &) const = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} |
| 12 |
|
| 13 |
// Declare the defaulted comparison function as a non-member function. |
| 14 |
bool operator==(const Foo &, const Foo &) = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} |
| 15 |
|
| 16 |
// Declare the defaulted comparison function as a non-member function. Arguments are passed by value. |
| 17 |
bool operator==(Foo, Foo) = default; // expected-warning {{comparing floating point with == or != is unsafe}} expected-note {{in defaulted equality comparison operator for 'Foo' first required here}} |