Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

clang++ prints bogus error: use of overloaded operator '!=' is ambiguous #49335

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR50366
Status NEW
Importance P enhancement
Reported by Yuri (yuri@tsoft.com)
Reported on 2021-05-16 12:30:01 -0700
Last modified on 2021-05-16 15:20:31 -0700
Version 10.0
Hardware PC FreeBSD
CC blitzrakete@gmail.com, dblaikie@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The Gecode project https://github.com/Gecode/gecode (release/6.3.0 branch
rev.ad52315) fails with -std=c++2a:

> In file included from gecode/float/var-imp/float.cpp:41:
> In file included from ./gecode/float.hh:833:
> ./gecode/float/val.hpp:319:18: error: use of overloaded operator '!=' is
ambiguous (with operand types 'const Gecode::FloatVal::FloatValImpType' (aka
'const interval<double,
>       policies<save_state<Float::Rounding>, checking_strict<double> > >') and
'const Gecode::FloatVal::FloatValImpType')
>       return x.x != y.x;
>              ~~~ ^  ~~~
> ./gecode/third-party/boost/numeric/interval/interval.hpp:85:8: note:
candidate function
>   bool operator!= (const interval_holder& r) const;
>        ^
> ./gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note:
candidate function
>   bool operator== (const interval_holder& r) const;
>        ^
> ./gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note:
candidate function (with reversed parameter order)
> In file included from gecode/float/rel.cpp:36:
> In file included from ./gecode/float/rel.hh:46:
> In file included from ./gecode/float.hh:833:
> ./gecode/float/val.hpp:296:18: warning: ISO C++20 considers use of overloaded
operator '==' (with operand types 'const Gecode::FloatVal::FloatValImpType'
(aka 'const interval<double,
>       policies<save_state<Float::Rounding>, checking_strict<double> > >') and
'const Gecode::FloatVal::FloatValImpType') to be ambiguous despite there being
a unique best viable function
>       [-Wambiguous-reversed-operator]
>       return x.x == y.x;
>              ~~~ ^  ~~~
> ./gecode/third-party/boost/numeric/interval/interval.hpp:84:8: note:
ambiguity is between a regular call to this operator and a call with the
argument order reversed
>   bool operator== (const interval_holder& r) const;
>        ^

Both operand types in the error message are same: 'const
Gecode::FloatVal::FloatValImpType'
It doesn't make sense that type order reversal can cause ambiguity.

Additionally, when compiled with -Wno-ambiguous-reversed-operator this error
message is still printed.
Quuxplusone commented 3 years ago

llvm-12 doesn't have this problem any more.