[patch libcpp]: Issue about st_size comparison
Dave Korn
dave.korn.cygwin@googlemail.com
Mon Aug 31 19:25:00 GMT 2009
Kai Tietz wrote:
Hi Kai... I don't understand this patch, so I have a few questions:
> on windows target x64 ssize_t has size of 64-bits, but the st_size
> field in struct stat remains for 32-bit API version 32-bit type long.
> So the comparison 'file->st.st_size > INTTYPE_MAXIMUM (ssize_t)' is
> always zero,
Why is that wrong, rather then the correct thing to happen? It means that
you can never have a file too large, because a 64-bit address space will
always swallow a 32-bit range of file offsets with room to spare.
> which leads for stage 2 build to fail.
In what way does it fail?
> - if (file->st.st_size > INTTYPE_MAXIMUM (ssize_t))
> + if ((ssize_t) file->st.st_size > INTTYPE_MAXIMUM (ssize_t))
In what way is the comparison not still always zero after this change? I
don't see how the compiler won't assume an ssize_t value (the casted value on
the LHS) could never exceed the INTTYPE_MAXIMUM for the type.
Oh, btw, trivial typo in the ChangeLog: "file.c" vs. "files.c"
cheers,
DaveK
More information about the Gcc-patches
mailing list