次のコード スニペットをご覧ください。
#include <stdio.h>
int main ()
{
FILE * pFile;
pFile = fopen ("c:\\Temp\\test.txt","rb");
if (pFile!=NULL)
{
printf("opened\n");
fclose (pFile);
}
else{
printf("error\n");
}
return 0;
}
このコード スニペットをコンパイルして実行すると、何も失敗しません。デバッグ モードでコードを実行すると、fopen は次のメッセージで失敗します。
Thread [1] 0 (Suspended : Signal : SIGSEGV:Segmentation fault)
wtoi64() at 0x77b35eab
wtoi64() at 0x77b35a70
ntdll!RtlpSetUserPreferredUILanguages() at 0x77ba5eff
ntdll!KiRaiseUserExceptionDispatcher() at 0x77b6a3ba
toi64() at 0x77b35a70
msvcrt!malloc() at 0x775c9d45
strcpy_s() at 0x775cf5d3
open_osfhandle() at 0x775d2b18
0x18
0xbf39e545
<...more frames...
開発環境:
Windows 7
Eclipse CDT Juno Service Release 1
MINGW 4.7
コンパイラ設定:
-O0 -g3 -Wall -c -fmessage-length=0
デバッガーを起動し、fopen(..) まで各命令を段階的に実行した場合に fopen が失敗する理由を知っている人はいますか?
あなたの答えを楽しみにしています。よろしくお願いします。