I am having a strange problem in my code. I have many asserts scattered around the code and all have been working fine. Whenever an assert failed I got a message giving me line number of where the failure happened. Today I wrote another assert in a function which loads a file. Just wanted to make sure that the fie existed. A very simple assert. Here is the relevant code:
//Check that the file exists and can be opened
FILE* f = fopen(filename, "rb");
#ifdef ASSERTIONS_ON
assert(f!=NULL);//@开发者_JAVA百科problem For some reason while all other asserts work, this one just crashes the program without reporting line
#else
if(f == NULL)
return MODEL_LOAD_FILENOTFOUND;
#endif
fclose(f);
I know that this does not help a lot but just wanted to showcase what my problem is. My OS is Windows 7. The compiler is GCC. The error message I get from Windows is the usual runtime error but without line reporting:
"The application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information"
What could be the problem? What can possibly cause an assert failure to just request termination without reporting a line where it happens, while in every other case in the same code it works as intended? Thanks in advance for any assistance!
You most likely have FUBAR'ed the stack somewhere before the assert executes.
精彩评论