On Sat, 18 Dec 2021 15:07:30 -0500
Ethan Sommer <e5ten.a...@gmail.com> 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:

  "Otherwise, if the new type is unsigned, the value is converted by
  repeatedly adding or subtracting one more than the maximum value that
  can be represented in the new type until the value is in the range of
  the new type."

With best regards

Laslo

Reply via email to