[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Link time optimization 'bug' report.
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 12 Jun 2020 15:18:37 -0300
> FYI: I compiled Lua using gcc LTO (Link Time Optimization) with
> optimization -O3. I got the following warning:
>
> ldebug.c: In function ‘lua_getinfo’:
> ltable.c:780:3: warning: ‘v.value_’ may be used uninitialized in this
> function [-Wmaybe-uninitialized]
> setobj2t(L, cell, value);
> ^
> ltable.c:780:3: warning: ‘v.value_’ may be used uninitialized in this
> function [-Wmaybe-uninitialized]
>
> [...]
The compiler only detects this instance, but Lua has had lots of
instances like that for a long time. The problem is that we have a
tagged union, and some tags don't need the union, and therefore don't
use it. In 5.4 that includes booleans, but nil is like that since
the beginning. Whenever we copy a nil TValue, we are accessing an
uninitialized value_ field.
Strictly, this seems to be undefined behavior in C (due to trap
representations), but I doubt any machine is capable of even detecting
that without going out of its way. (For instance, we are allowed to
assign the whole structure containing this undefined union, even if we
cannot assign only the union.)
-- Roberto