次のコードは、std::stringをキーとして使用してstd::mapの使用をテストします。
#include <stdio.h>
#include <map>
#include <string>
using namespace std;
typedef map<string, int> test_map_t;
int main(int argc, char **argv) {
test_map_t test_map;
test_map["test1"]= 1;
test_map["test2"]= 2;
test_map["test3"]= 3;
string tmp= "test1";
printf("%s : %d \n", tmp.c_str(), test_map[tmp]);
return 0;
}
通常のgccでコンパイルすると、このテストは期待どおりに「test1:1」を出力します。ただし、alchemyでコンパイルすると、「test1:3」(!)が出力されます。ここで何かが非常に間違っています。
これに対する回避策はありますか、それとも私は立ち往生していますか?