[patch libcpp]: Issue about st_size comparison

Kai Tietz ktietz70@googlemail.com
Mon Aug 31 19:48:00 GMT 2009


2009/8/31 Dave Korn <dave.korn.cygwin@googlemail.com>:
> 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
>

Hi Dave,

The issue is that gcc is clever enough to detect that a comparison of
long > long long (max), can never be true. So it emits a warnings. As
libcpp uses -Werrror - as you surely know - build fails.

Thanks for the hint for changelog.

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination



More information about the Gcc-patches mailing list