[Bug libstdc++/13489] New: Superfluous function void std::swap(std::_Bit_reference, std::_Bit_reference)

denis dot nagorny at intel dot com gcc-bugzilla@gcc.gnu.org
Thu Dec 25 15:56:00 GMT 2003


Libstdc++ has contain superfluous function void std::swap(std::_Bit_reference,
std::_Bit_reference) in stl_bvector.h.
C++ standard 23.2.5 [lib.vector.bool] doesn't define such function.
Following sample demonstrates invalid behaviour of such extension:

$cat sample.cpp

#include <cstdio>
#include <vector>
using namespace std;
// As C++ standard doesn't define this function we can do it by ourself.
void swap(vector<bool>::reference left,vector<bool>::reference right)
{
        puts("Some another");
}

int foo(std::vector<bool> &a,std::vector<bool> &b)
{
        swap(*a.begin(),*b.begin());
        return 0;
}
/////////////////////

$g++ -c sample.cpp
$ g++ sample.cpp -c 
sample.cpp: In function `int foo(std::vector<bool, std::allocator<bool> >&, 
   std::vector<bool, std::allocator<bool> >&)':
sample.cpp:12: call of overloaded `swap(std::_Bit_reference, 
   std::_Bit_reference)' is ambiguous
sample.cpp:6: candidates are: void swap(std::_Bit_reference, 
   std::_Bit_reference)
/usr/include/c++/3.2/bits/stl_bvector.h:95:                 void 
   std::swap(std::_Bit_reference, std::_Bit_reference)

-- 
           Summary: Superfluous function void std::swap(std::_Bit_reference,
                    std::_Bit_reference)
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: denis dot nagorny at intel dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13489



More information about the Gcc-bugs mailing list