lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Roberto Ierusalimschy wrote:
> When compiling Lua 5.1.4 with gcc (version 4.4.3) with option
> -Wstrict-overflow=2, I get two warnings that I cannot understand:
> 
> lvm.c: In function ‘luaV_concat’:
> lvm.c:300: warning: assuming signed overflow does not occur when simplifying conditional to constant

GCC deduces that n >= 1 from scalar evolution analysis earlier in
line 293. SCEV assumes that n++ does not overflow. You get the
warning in line 300 because the loop entry condition has been
eliminated based on SCEV and VRP (value range propagation).

> lua.c: In function ‘pmain’:
> lua.c:353: warning: assuming signed overflow does not occur when simplifying conditional to constant

The control-flow of collectargs() is inlined and only the paths
that return -1 enter the conditional in line 353. All others don't
need to check for the conditional due to SCEV analysis of the loop
in line 263 and VRP.

http://gcc.gnu.org/onlinedocs/gccint/Scalar-evolutions.html

LuaJIT source: src/lj_jit.h, struct ScEvEntry. ;-)

> Does anyone have a clue about the cause of these warnings and/or how
> to remove them? (The question is not about that kind of warning in
> general, but why gcc signals it in these two specific cases.)

You can disable specific warnings with pragmas in more recent GCC
versions. Since the assumptions of the compiler are in fact
correct in this case, you can just ignore the warnings.

--Mike