> Le 15 mars 2019 à 18:28, Akim Demaille <[email protected]> a écrit :
>
> Hi Paul,
>
>> Le 14 mars 2019 à 22:26, Paul Eggert <[email protected]> a écrit :
>>
>> On 3/14/19 1:43 PM, Akim Demaille wrote:
>>
>>> + return column <= INT_MAX - width ? column + width : INT_MAX;
>>
>> Nowadays a better (i.e., more-efficient, and I think easier-to-follow)
>> way of writing this is:
>>
>> int result;
>> return INT_ADD_WRAPV (column, width, &result) : INT_MAX : result;
>>
>> where INT_ADD_WRAPV is defined in intprops.h.
>
> Excellent! Thanks a lot. I'll install the following when the CI confirms it.
GCC 4.9, 4.7 and 4.6 generate warnings about this.
For instance https://travis-ci.org/akimd/bison/jobs/506935039
src/location.c: In function 'add_column_width':
./lib/intprops.h:430:50: error: comparison is always false due to limited range
of data type [-Werror=type-limits]
|| (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
^
And Clang 3.3, 3.4. For instance
https://travis-ci.org/akimd/bison/jobs/506935052
src/location.c:45:10: error: comparison of constant -9223372036854775808 with
expression of type 'int' is always false
[-Werror,-Wtautological-constant-out-of-range-compare] CC src/bison-lr0.o
return INT_ADD_WRAPV (column, width, &res) ? INT_MAX : res;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The whole result is here: https://travis-ci.org/akimd/bison/builds/506935032.
Are you aware of any way to use this macro and avoid these spurious warnings?