i open a file for binary read with fopen, and i do (in this order) a fseek,
ftell, fseek, and then an fread. the program runs fine with the exact same
code in C, but when i compile it as C++, the program crashes. i used FSDB,
and i found that fread's ret is going to some weird place that is definately
not where it should go. it crashes 3 instructions later. this is with
no optimizations at all...just gxx test.cpp -o test.exe. however, something
i found quite interesting, is that when i add -O1, -O2, or -O3, it runs
absolutely fine. i'm guessing the bug is in fread's code?
btw, here's some of the code
char *DMA_Buffer;
FILE *f;
int len;
f = fopen("test.raw", "rb"); // test.raw is 41100 bytes
fseek(f, 0, 2);
len = ftell(f);
fseek(f, 0, 0);
fread(DMA_Buffer, len, 1, f); // heres the buggy line
fclose(f);