Re: An unsigned overflow in luai_makeseed()

Błażej Roszkowski <[email protected]>
Newsgroups gmane.comp.lang.lua.general
Message-ID <CAOc0etGemLFAajgmKGMYwHjRfkjMZPenkz0R3rL7u9cHzGmwDg@mail.gmail.com>
AFAIK unsigned overflow is and always was defined in both C and C++ to just
be modulo arithmetics.

On Tue, 17 Feb 2026 at 10: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/CAOc0etGemLFAajgmKGMYwHjRfkjMZPenkz0R3rL7u9cHzGmwDg%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.