Compiler details:
Target: mingw32
Configured with: ../../configure --prefix=/mingw --host=mingw32
--target=mingw32 --program-prefix= --with-as=/mingw/bin/
as.exe --with-ld=/mingw/bin/ld.exe --with-gcc --with-gnu-ld --with-gnu-as
--enable-threads --disable-nls --enable-langua
ges=c,c++ --disable-win32-registry --disable-shared --without-x
--enable-interpreter --enable-hash-synchronization --ena
ble-libstdcxx-debug --with-gmp-include=/projects/common/GMP/4.3.1
--with-gmp-lib=/projects/common/GMP/4.3.1/.libs --with
-mpfr-include=/projects/common/MPFR/2.4.1
--with-mpfr-lib=/projects/common/MPFR/2.4.1/.libs
Thread model: win32
gcc version 4.5.0 20090421 (experimental - lambda branch) (GCC)
Insertion into std::tr1::unordered_map generates segmentation fault. Here is
code sample:
#include
#include
#include
#include
#include
#include
class ABC
{
public:
ABC() : m_A(0) {;}
ABC(int a) : m_A(a) {;}
int A() const {return m_A;}
bool operator ==(ABC const& other) const {return m_A == other.m_A;}
private:
int m_A;
friend std::ostream& operator << (std::ostream& os, ABC const& obj)
{
os << obj.m_A;
return os;
}
};
struct hash_ABC : std::unary_function
{
size_t operator()(ABC const& v) const {return v.A();}
};
int main()
{
typedef std::unordered_map dict_t;
dict_t dic;
ABC key(2);
dic.insert(std::make_pair(ABC(1), std::string("One")));
dic.insert(std::make_pair(key, std::string("Two")));
dic.insert(std::make_pair(ABC(3), std::string("Three")));
return 0;
}
My own investigations were shown what problem is within _M_allocate_node
function (include\c++\tr1_impl\hashtable, line #477). When I removed
__try/__catch block from this function all start work fine. In the original
case this function returns strange value (sometimes NULL, sometimes garbage).
--
Summary: unordered_map insertion generates seg fault
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: comm_wolf at mail dot ru
GCC build triplet: i386-pc-mingw
GCC host triplet: i386-pc-mingw
GCC target triplet: i386-pc-mingw
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40939