Re: [hackers] [libgrapheme] Use SIZE_MAX instead of (size_t)-1 || Laslo Hunhold

2021-12-18 Thread Laslo Hunhold
On Sat, 18 Dec 2021 15:07:30 -0500 Ethan Sommer wrote: Dear Ethan, > > (size_t)-1 is also undefined behaviour. > > It isn't, wrap-around with unsigned types is defined, it's only signed > overflow that isn't. yes, exactly. For posterity, the standard specifies that in 6.3.1.3p2:

Re: [hackers] [libgrapheme] Use SIZE_MAX instead of (size_t)-1 || Laslo Hunhold

2021-12-18 Thread Mattias Andrée
It appears you are correct, I've been tricked by some tool that checked for undefined behaviour during runtime (don't remember which, it was an website that forced it upon the user). Casting a signed value X to unsigned is for an N-bit integer shall result in the number that that is congruent with

Re: [hackers] [libgrapheme] Use SIZE_MAX instead of (size_t)-1 || Laslo Hunhold

2021-12-18 Thread Ethan Sommer
On Sat, Dec 18, 2021 at 3:02 PM Mattias Andrée wrote: > (size_t)-1 is also undefined behaviour. It isn't, wrap-around with unsigned types is defined, it's only signed overflow that isn't. > On Sat, 18 Dec 2021 20:21:42 +0100 > wrote: > > > commit cb7e9c00899ae0ed57a84991308b7f880f4ddef6 > >

Re: [hackers] [libgrapheme] Use SIZE_MAX instead of (size_t)-1 || Laslo Hunhold

2021-12-18 Thread Mattias Andrée
(size_t)-1 is also undefined behaviour. On Sat, 18 Dec 2021 20:21:42 +0100 wrote: > commit cb7e9c00899ae0ed57a84991308b7f880f4ddef6 > Author: Laslo Hunhold > AuthorDate: Sat Dec 18 20:21:04 2021 +0100 > Commit: Laslo Hunhold > CommitDate: Sat Dec 18 20:21:04 2021 +0100 > > Use