https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121663
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Looks like that. LOCATION_LINE is int, so when #line overflows it becomes
negative up to -2 and -1. The hash_map uses int_hash<int64_t, -1, -2> though,
which is 64-bit signed with -1 and -2 special values (Empty and Deleted).
So, one possibility would be
--- gcc/tree-cfg.cc.jj 2025-08-23 15:00:04.928779140 +0200
+++ gcc/tree-cfg.cc 2025-09-01 15:50:45.491819750 +0200
@@ -1098,7 +1098,8 @@ assign_discriminator (location_t loc, un
hash_map<int_hash <int64_t, -1, -2>, discrim_entry> &map)
{
bool existed;
- discrim_entry &e = map.get_or_insert (LOCATION_LINE (loc), &existed);
+ discrim_entry &e
+ = map.get_or_insert ((unsigned) LOCATION_LINE (loc), &existed);
gcc_checking_assert (!has_discriminator (loc));
if (!existed)
{
Another one would be to use int_hash <unsigned, -1U, -2U> instead and simply
don't try to assign any discriminators for line (unsigned) LOCATION_LINE (loc)
>= -2U.
Note, out of range #line numbers are diagnosed with -pedantic (and error with
-pedantic-errors) but we still ICE after that.