Hi.

The patch handles an undefined behavior caused by 1U << 32 shift
for an integer type.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

libcpp/ChangeLog:

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 *>

Reply via email to