Subject: Re: bug#49261: Segfault during loadup

From: Eli Zaretskii <[email-masked]>
Date: Mon, 12 Jul 2021 15:07:32 +0300

> Cc: [email-masked], [email-masked]
> From: Paul Eggert <[email-masked]>
> Date: Mon, 12 Jul 2021 00:16:07 -0700
> 
> >>    lisp.h:251:18: warning: unsigned conversion from 'long long int' to 'uintptr_t' {aka 'unsigned int'} changes value from '2305843009213693951' to '4294967295' [-Woverflow]
> >>      251 | # define VALMASK (USE_LSB_TAG ? - (1 << GCTYPEBITS) : VAL_MAX)
> >> 	|                  ^
> >>    alloc.c:4767:24: note: in expansion of macro 'VALMASK'
> >>     4767 |       uintptr_t mask = VALMASK;
> >> 	|                        ^~~~~~~
> > I tried to fix this on master, please take a look.
> 
> Yes that GCC warning was bogus, and your pacification of GCC is valid 

Hmm... is it really a bogus warning?  VALMASK is a 64-bit value, and
uintptr_t is 32-bit wide.

> now that we no longer tag the MSB of pointers. Still, there should be a 
> simpler way to pacify GCC so I installed a further fix that I hope does 
> that (see first attached patch). This fix simply uses a cast (uintptr_t) 
> VALMASK to pacify GCC; if GCC issues a bogus warning even for that cast, 
> we could substitute (uintptr_t) (VALMASK & UINTPTR_MAX) though this is 
> starting to get a little ridiculous.

Your fix compiles cleanly, thanks.