Re: An unsigned overflow in luai_makeseed()
Андрей Закатов <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <CAKmTuAKUWPd-maRYyVF1ZvkHM_jm9FtA1+wbyC-BVdZCTYSPDQ@mail.gmail.com> |
AFAIK it's the signed overflow that is considered UB, and unsigned operations are defined with modular arithmetic, no? On Tue, Feb 17, 2026, 11:50 Sergey Bronnikov <[email protected]> wrote: > Hello, > > the function luai_makeseed() in lauxlib.c has the following expression [1]: > > res ^= (res >> 3) + (res << 7) + buff[i]; > > where res has type "unsigned integer". This arithmetic has an unsigned > overflow. > This is of course undefined behavior from a language point of view, but > maybe it is used here intentionally? > > 1. > https://github.com/lua/lua/blob/c6b484823806e08e1756b1a6066a3ace6f080fae/lauxlib.c#L1167 > > Sergey > > -- > You received this message because you are subscribed to the Google Groups > "lua-l" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion visit > https://groups.google.com/d/msgid/lua-l/c36ec376-99a3-4869-9881-46eb9dde1a6cn%40googlegroups.com > <https://groups.google.com/d/msgid/lua-l/c36ec376-99a3-4869-9881-46eb9dde1a6cn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/CAKmTuAKUWPd-maRYyVF1ZvkHM_jm9FtA1%2BwbyC-BVdZCTYSPDQ%40mail.gmail.com.