Skip to content

Commit b5c2fa1

Browse files
authored
[libc] Mark operator== const to avoid ambiguity in C++20. (#68805)
C++20 will automatically generate an operator== with reversed operand order, which is ambiguous with the written operator== when one argument is marked const and the other isn't. This operator currently triggers -Wambiguous-reversed-operator at usage site libc/test/UnitTest/PrintfMatcher.cpp:28.
1 parent 1379a72 commit b5c2fa1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libc/src/stdio/printf_core/core_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct FormatSection {
5353

5454
// This operator is only used for testing and should be automatically
5555
// optimized out for release builds.
56-
bool operator==(const FormatSection &other) {
56+
bool operator==(const FormatSection &other) const {
5757
if (has_conv != other.has_conv)
5858
return false;
5959

0 commit comments

Comments
 (0)