[llvm-bugs] [Bug 43765] New: operator== and operator!= became ambiguous
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 22 17:25:24 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43765
Bug ID: 43765
Summary: operator== and operator!= became ambiguous
Product: clang
Version: trunk
Hardware: All
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: code at extbit.io
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
As of to the revision `65acf43270ea2894dffa0d0b292b92402f80c8cb` of clang, the
two operators became the "same" and causes ambiguous. My last working clang
without these issue was built at Oct 16 01:40.
The failure screen should be looking like this:
<code>
/Users/duzy/workspace/toolchain/source/lib/Support/Options.cpp:20:38: error:
use of overloaded operator '!=' is ambiguous (with operand types
'llvm::DenseMapIterator<void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *>, false>' and
'llvm::DenseMapBase<llvm::DenseMap<void *, llvm::cl::Option *,
llvm::DenseMapInfo<void *>, llvm::detail::DenseMapPair<void *, llvm::cl::Option
*> >, void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *> >::iterator' (aka
'DenseMapIterator<void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *> >'))
for (auto IT = Options.begin(); IT != Options.end(); ++IT)
~~ ^ ~~~~~~~~~~~~~
/Users/duzy/workspace/toolchain/source/include/llvm/ADT/DenseMap.h:1222:8:
note: candidate function
bool operator!=(const ConstIterator &RHS) const {
^
/Users/duzy/workspace/toolchain/source/include/llvm/ADT/DenseMap.h:1215:8:
note: candidate function
bool operator==(const ConstIterator &RHS) const {
^
/Users/duzy/workspace/toolchain/source/include/llvm/ADT/DenseMap.h:1215:8:
note: candidate function (with reversed parameter order)
/Users/duzy/workspace/toolchain/source/lib/Support/Options.cpp:25:28: warning:
ISO C++20 considers use of overloaded operator '==' (with operand types
'llvm::DenseMapBase<llvm::DenseMap<void *, llvm::cl::Option *,
llvm::DenseMapInfo<void *>, llvm::detail::DenseMapPair<void *, llvm::cl::Option
*> >, void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *> >::iterator' (aka
'DenseMapIterator<void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *> >') and
'llvm::DenseMapBase<llvm::DenseMap<void *, llvm::cl::Option *,
llvm::DenseMapInfo<void *>, llvm::detail::DenseMapPair<void *, llvm::cl::Option
*> >, void *, llvm::cl::Option *, llvm::DenseMapInfo<void *>,
llvm::detail::DenseMapPair<void *, llvm::cl::Option *> >::iterator') to be
ambiguous despite there being a unique best viable function
[-Wambiguous-reversed-operator]
assert(Options.find(Key) == Options.end() &&
~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/assert.h:93:25:
note: expanded from macro 'assert'
(__builtin_expect(!(e), 0) ? __assert_rtn(__func__, __FILE__, __LINE__, #e)
: (void)0)
^
/Users/duzy/workspace/toolchain/source/include/llvm/ADT/DenseMap.h:1215:8:
note: ambiguity is between a regular call to this operator and a call with the
argument order reversed
bool operator==(const ConstIterator &RHS) const {
^
1 warning and 1 error generated.
</code>
The invocation is like this:
<code>
/Users/duzy/workspace/toolchain/bootstrap/bin/clang++ -Ofast -std=c++2a -fPIC
-fvisibility-inlines-hidden -I/Users/duzy/workspace/toolchain/private/include
-I/Users/duzy/workspace/toolchain/include
-I/Users/duzy/workspace/toolchain/source/include -c
/Users/duzy/workspace/toolchain/source/lib/Support/Options.cpp -o
/Users/duzy/workspace/toolchain/.smart/tmp/llvm/Support/.building/Options.o
</code>
The steps how I work to build are:
1. Build llvm+clang with my system /usr/bin/clang for
toolchain/bootstrap/bin/clang
2. Build llvm+clang again with toolchain/bootstrap/bin/clang (aka. building
itself)
3. Should fail when compiling llvm/lib/Support/Options.cpp
The "error" code is (which is actually fine) (at
/Users/duzy/workspace/toolchain/source/include/llvm/ADT/DenseMap.h:1222):
bool operator==(const ConstIterator &RHS) const {
assert((!Ptr || isHandleInSync()) && "handle not in sync!");
assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!");
assert(getEpochAddress() == RHS.getEpochAddress() &&
"comparing incomparable iterators!");
return Ptr == RHS.Ptr;
}
bool operator!=(const ConstIterator &RHS) const {
assert((!Ptr || isHandleInSync()) && "handle not in sync!");
assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!");
assert(getEpochAddress() == RHS.getEpochAddress() &&
"comparing incomparable iterators!");
return Ptr != RHS.Ptr;
}
When I changed the operator!= (or both) like this the compilation continue
again:
template <bool IsConst>
bool operator!=(const DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket,
IsConst> &RHS) const {
assert((!Ptr || isHandleInSync()) && "handle not in sync!");
assert((!RHS.Ptr || RHS.isHandleInSync()) && "handle not in sync!");
assert(getEpochAddress() == RHS.getEpochAddress() &&
"comparing incomparable iterators!");
return Ptr != RHS.Ptr;
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191023/c96b8425/attachment-0001.html>
More information about the llvm-bugs
mailing list