This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4] gcc/c-family/c-cppbuiltin.c: Let buffer enough to print host wide integer value


On 11/27/14 07:41, Chen Gang wrote:
> OK, I shall send related test case within two weeks (2014-12-10).
> 
> Joseph Myers <joseph@codesourcery.com> wrote:
> 
> On Thu, 27 Nov 2014, Chen Gang wrote:
> 
>> The original length 18 is not enough for HOST_WIDE_INT printing, need
>> use 20 instead of.
>>
>> Also need additional bytes for printing related prefix and suffix, and
>> give a related check.
>>
>> It passes testsuite under fedora 20 x86_64-unknown-linux-gnu.
>>
>> 2014-11-27  Chen Gang <gang.chen.5i5j@gmail.com>
>>
>>         * c-family/c-cppbuiltin.c (builtin_define_with_int_value): Let
>>         buffer enough to print host wide integer value.
> 
> OK.  Properly implementing the (-9223372036854775807LL-1) and similar 
> cases (when the value is the least int, long or long long on the target) 
> can be a followup fix.
> 

Sorry, after check all related callers, at present, it can not cause
real world issue:

 - builtin_define_with_int_value() is static function which is only used
   within 'c-cppbuiltin.c'.

 - except builtin_define_type_sizeof(), all callers wants to use 'int'
   for 'value', and in fact, builtin_define_type_sizeof() uses a small
   integer too (although it use HOST_WIDE_INT).

 - for 'flag_abi_version' (can be customized by '-fabi-version=??'):

   '999999' will over flow 16-bit 'int', but will cast to HOST_WIDE_INT
   automatically, which will not cause real issue.

   '1000 + flag_abi_version' may over flow 32-bit 'int', but still will
   cast to HOST_WIDE_INT automatically, which will not cause real issue.

So for me, at present, current patch is not a current bug fix patch, but
I guess, it is still useful in the future (the related code really need
be improved).


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]