[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: address warnings from GCC's UB sanitizer
From: |
Akim Demaille |
Subject: |
Re: address warnings from GCC's UB sanitizer |
Date: |
Sat, 16 Mar 2019 07:42:37 +0100 |
> Le 15 mars 2019 à 18:28, Akim Demaille <address@hidden> a écrit :
>
> Hi Paul,
>
>> Le 14 mars 2019 à 22:26, Paul Eggert <address@hidden> 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?
- address warnings from GCC's UB sanitizer, Akim Demaille, 2019/03/14
- Re: address warnings from GCC's UB sanitizer, Paul Eggert, 2019/03/14
- Re: address warnings from GCC's UB sanitizer, Akim Demaille, 2019/03/15
- Re: address warnings from GCC's UB sanitizer,
Akim Demaille <=
- Re: address warnings from GCC's UB sanitizer, Paul Eggert, 2019/03/16
- Re: address warnings from GCC's UB sanitizer, Paul Eggert, 2019/03/16
- Re: address warnings from GCC's UB sanitizer, Akim Demaille, 2019/03/16
- Re: address warnings from GCC's UB sanitizer, Paul Eggert, 2019/03/20
- Re: address warnings from GCC's UB sanitizer, Akim Demaille, 2019/03/20