私はunordered_map
C++ でハッシュマップとして使用していますが、そこに何かを保存しようとすると、次のようになります。
Floating point exception: 8
誰がエラーが何であるかを指摘できますか? 以下は、マップを初期化する方法です (table_entry
は単なる構造体です)。
std::tr1::unordered_map<unsigned short, table_entry*> forwarding_table;
それから私は次のようにしてエントリを入れていました:
unsigned short dest_id = 0;
table_entry *entry = (table_entry *)malloc(sizeof(table_entry));
forwarding_table[dest_id] = entry;
私の構造体の定義は次のとおりです。
typedef struct table_entry {
unsigned short next_hop;
unsigned int cost;
} table_entry;
コンパイラのバージョンに関しては、実行すると次のg++ -v
ようになります。
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1