これでC++について私が気付いていない明らかな何かがあるに違いありません。
load(string & filename){
string command;
char delimiter = '/';
size_t delimiterPos = filename.rfind(delimiter);
string directory = string(filename.c_str(),delimiterPos);
command = "import path ";
//want to add directory to end of command
string temp = command + "hello!"; // This works
command.append(directory); //This works!
command += directory; //This seg faults!
...
}
関数の先頭でファイル名を「出力」すると、GDB で次のようになります: (const string &) @0x9505f08: {static npos = 4294967295, _M_dataplus = {> = {<__gnu_cxx::new_allocator> = {}, }, _M_p = 0x950a8e4 "../config/pythonFile.py"}}
一体、.append() が機能し、+= が機能しないように、ファイル名が正しくフォーマットされていないのはどうしてですか?! C++ のオーバーロードされた関数 += に奇妙な点がありますか?
g++ バージョン 3.4.6