Skip to content

Commit 1c108c8

Browse files
Mark operator== const to avoid errors when asserts are enabled
Without this change, the build will fail like so: llvm-project/lld/MachO/ObjC.cpp:1387:75: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'ObjcCategoryMerger::PointerListInfo' and 'ObjcCategoryMerger::PointerListInfo') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator] 1387 | parseProtocolListInfo(classIsec, roClassLayout.baseProtocolsOffset) == | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ 1388 | parseProtocolListInfo(metaIsec, roClassLayout.baseProtocolsOffset) && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/assert.h:100:27: note: expanded from macro 'assert' 100 | (static_cast <bool> (expr) \ | ^~~~ llvm-project/lld/MachO/ObjC.cpp:391:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed 391 | inline bool operator==(const PointerListInfo &cmp) { | ^ llvm-project/lld/MachO/ObjC.cpp:391:17: note: mark 'operator==' as const or add a matching 'operator!=' to resolve the ambiguity 1 error generated.
1 parent 5bfe4b9 commit 1c108c8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lld/MachO/ObjC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class ObjcCategoryMerger {
388388
: categoryPrefix(_categoryPrefix),
389389
pointersPerStruct(_pointersPerStruct) {}
390390

391-
inline bool operator==(const PointerListInfo &cmp) {
391+
inline bool operator==(const PointerListInfo &cmp) const {
392392
return pointersPerStruct == cmp.pointersPerStruct &&
393393
structSize == cmp.structSize && structCount == cmp.structCount &&
394394
allPtrs == cmp.allPtrs;

0 commit comments

Comments
 (0)