[Bug libstdc++/96303] [10/11 Regression] Ambiguous overload for operator!= for std::__debug::bitset compiled with -std=c++20 and -pedantic.
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 7 19:46:36 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96303
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:
https://gcc.gnu.org/g:7e26e4fbd4ee618dd991c6bbf3c5403aa90d2192
commit r10-8592-g7e26e4fbd4ee618dd991c6bbf3c5403aa90d2192
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Aug 7 20:29:11 2020 +0100
libstdc++: Fix ambiguous comparisons in __gnu_debug::bitset [PR 96303]
With -pedantic the debug mode bitset has an ambiguous equality
comparison operator, because it tries to compare the non-debug base to
the debug object. The base object can be converted to another debug
bitset, making the same operator== a candidate again.
The fix is to do the comparison on both base objects, so the operator
for the derived type isn't a candidate.
For the inequality operator the same change should be done, but that
operator can be removed entirely for C++20 because it can be synthesized
by the compiler.
I don't think either equality or inequality operators are really needed,
because the public _GLIBCXX_STD_C::bitset base class cam always be
compared using its own comparison operators. I'm not changing that here
though.
libstdc++-v3/ChangeLog:
PR libstdc++/96303
* include/debug/bitset (bitset::operator==): Call _M_base() on
right operand.
(bitset::operator!=): Likewise, but don't define it at all when
default comparisons are supported by the compiler.
* testsuite/23_containers/bitset/operations/96303.cc: New test.
(cherry picked from commit de1e3b8795e507c3cfa5b62984272628ca62a9bd)
More information about the Gcc-bugs
mailing list