On 2/18/19 9:54 AM, Jakub Jelinek wrote:
> On Mon, Feb 18, 2019 at 09:46:33AM +0100, Martin Liška wrote:
>> Hi.
>>
>> The patch handles an undefined behavior caused by 1U << 32 shift
>> for an integer type.
> 
> That will still ICE on 32-bit hosts, won't it?
> So, either you need ((uint64_t) 1) << ..., or column_bits && ... >= ...

Ah, thanks! I'm going to install the former one.

Martin

> 
>> 2019-02-18  Martin Liska  <mli...@suse.cz>
>>
>>      PR c++/89383
>>      * line-map.c (linemap_line_start): Use 1UL in order
>>      to not overflow.
>> ---
>>  libcpp/line-map.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>
> 
>> diff --git a/libcpp/line-map.c b/libcpp/line-map.c
>> index 0e30b4b2b39..284bbd74009 100644
>> --- a/libcpp/line-map.c
>> +++ b/libcpp/line-map.c
>> @@ -745,7 +745,7 @@ linemap_line_start (struct line_maps *set, linenum_type 
>> to_line,
>>        || ( /* We can't reuse the map if the line offset is sufficiently
>>                large to cause overflow when computing location_t values.  */
>>            (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
>> -          >= (1U << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
>> +          >= (1UL << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
>>        || range_bits < map->m_range_bits)
>>      map = linemap_check_ordinary
>>              (const_cast <line_map *>
>>
> 
> 
>       Jakub
> 

Reply via email to