https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96303

            Bug ID: 96303
           Summary: Ambiguous overload for operator!= for
                    std::__debug::bitset compiled with -std=c++20 and
                    -pedantic.
           Product: gcc
           Version: 10.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt.lawson at precisionplanting dot com
  Target Milestone: ---

Hello,

In gcc/g++ 10.1.1, the following code produces an ambiguous overload for
std::__debug::bitset's operator!= when compiled with -D _GLIBCXX_DEBUG
-std=c++20 -pedantic (see bottom for full -v -save-temps output):


#include <bitset>

int main()
{
  std::bitset<5> x, y;
  return x != y;
}


When compiling without _GLIBCXX_DEBUG defined, the non-debug bitset does not
produce the same error.  Likewise, it does not produce error when compiling
with gcc/g++ 9, a previous C++ standard, or without -pedantic.  

It seems the non-debug bitset was updated for P1614R2 (commit
596676d66cab21e5ed85669e737af5b62f067d57), but the debug bitset was not, so the
fix may be as simple as applying the same changes to the debug bitset.

Thanks


Full -f -save-temps output:

g++ -v -save-temps  ~/Desktop/debug_bitset.cpp -o ~/Desktop/debug_bitset.o -D
_GLIBCXX_DEBUG -std=c++20 -Wall -Wextra -pedantic -fpermissive
-fno-strict-aliasing -fwrapv 
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/10/lto-wrapper
OFFLOAD_TARGET_NAMES=hsa:nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d
--enable-offload-targets=hsa,nvptx-none=/usr/nvptx-none,amdgcn-amdhsa=/usr/amdgcn-amdhsa,
--without-cuda-driver --enable-checking=release --disable-werror
--with-gxx-include-dir=/usr/include/c++/10 --enable-ssp --disable-libssp
--disable-libvtv --disable-cet --disable-libcc1 --enable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-libphobos
--enable-version-specific-runtime-libs --with-gcc-major-version-only
--enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function
--program-suffix=-10 --without-system-libunwind --enable-multilib
--with-arch-32=x86-64 --with-tune=generic
--with-build-config=bootstrap-lto-lean --enable-link-mutex
--build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.1 20200625 [revision c91e43e9363bd119a695d64505f96539fa451bf2]
(SUSE Linux) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o'
'/home/mlawson/Desktop/debug_bitset.o' '-D' '_GLIBCXX_DEBUG' '-std=c++2a'
'-Wall' '-Wextra' '-Wpedantic' '-fpermissive' '-fno-strict-aliasing' '-fwrapv'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/10/cc1plus -E -quiet -v -D_GNU_SOURCE -D
_GLIBCXX_DEBUG /home/mlawson/Desktop/debug_bitset.cpp -mtune=generic
-march=x86-64 -std=c++2a -Wall -Wextra -Wpedantic -fpermissive
-fno-strict-aliasing -fwrapv -fpch-preprocess -o debug_bitset.ii
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/10
 /usr/include/c++/10/x86_64-suse-linux
 /usr/include/c++/10/backward
 /usr/lib64/gcc/x86_64-suse-linux/10/include
 /usr/local/include
 /usr/lib64/gcc/x86_64-suse-linux/10/include-fixed
 /usr/lib64/gcc/x86_64-suse-linux/10/../../../../x86_64-suse-linux/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o'
'/home/mlawson/Desktop/debug_bitset.o' '-D' '_GLIBCXX_DEBUG' '-std=c++2a'
'-Wall' '-Wextra' '-Wpedantic' '-fpermissive' '-fno-strict-aliasing' '-fwrapv'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib64/gcc/x86_64-suse-linux/10/cc1plus -fpreprocessed debug_bitset.ii
-quiet -dumpbase debug_bitset.cpp -mtune=generic -march=x86-64 -auxbase
debug_bitset -Wall -Wextra -Wpedantic -std=c++2a -version -fpermissive
-fno-strict-aliasing -fwrapv -o debug_bitset.s
GNU C++17 (SUSE Linux) version 10.1.1 20200625 [revision
c91e43e9363bd119a695d64505f96539fa451bf2] (x86_64-suse-linux)
        compiled by GNU C version 10.1.1 20200625 [revision
c91e43e9363bd119a695d64505f96539fa451bf2], GMP version 6.2.0, MPFR version
4.0.2-p6, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (SUSE Linux) version 10.1.1 20200625 [revision
c91e43e9363bd119a695d64505f96539fa451bf2] (x86_64-suse-linux)
        compiled by GNU C version 10.1.1 20200625 [revision
c91e43e9363bd119a695d64505f96539fa451bf2], GMP version 6.2.0, MPFR version
4.0.2-p6, MPC version 1.1.0, isl version isl-0.22.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 00000000000000000000000000000000
In file included from /usr/include/c++/10/bitset:1595,
                 from /home/mlawson/Desktop/debug_bitset.cpp:1:
/usr/include/c++/10/debug/bitset: In instantiation of ‘bool
std::__debug::bitset<_Nb>::operator!=(const std::__debug::bitset<_Nb>&) const
[with long unsigned int _Nb = 5]’:
/home/mlawson/Desktop/debug_bitset.cpp:6:15:   required from here
/usr/include/c++/10/debug/bitset:360:26: error: ambiguous overload for
‘operator!=’ (operand types are ‘const _Base’ {aka ‘const
std::__cxx1998::bitset<5>’} and ‘const std::__debug::bitset<5>’)
  360 |       { return _M_base() != __rhs; }
      |                ~~~~~~~~~~^~~~~~~~
/usr/include/c++/10/debug/bitset:355:7: note: candidate: ‘bool
std::__debug::bitset<_Nb>::operator==(const std::__debug::bitset<_Nb>&) const
[with long unsigned int _Nb = 5]’ (reversed)
  355 |       operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
In file included from /home/mlawson/Desktop/debug_bitset.cpp:1:
/usr/include/c++/10/bitset:1306:7: note: candidate: ‘bool
std::__cxx1998::bitset<_Nb>::operator==(const std::__cxx1998::bitset<_Nb>&)
const [with long unsigned int _Nb = 5]’ (rewritten)
 1306 |       operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~

Reply via email to