Thu 10 Mar 2011 11:22:38 AM UTC, comment #7:
Ah! Then this is a simple case of buffer overflow.
I think the bug is in tu_file::seek(std::streampos pos).
On your 64-bit machine size_t is a 64-bit integer, so that the following line:
if (static_cast<size_t>(pos) > size()) return false;
actually returns false, because the file size is too large. So that's why you can't reproduce the assertion on the 64-bit machine.
On the 32-bit machine, the 64-bit integer (std::streampos) overflows in the static_cast to size_t, which is 32-bits. It then becomes a relatively small number, which is a reasonable number for a file size.
In the call to fseek, the integer again gets cast to a long (32-bit), again turning it into a small number.
A little while later the assertion compares the original streampos (a very large number) to the current file position, and lo and behold, it is not where it is supposed to be.
|