lua-users home
lua-l archive

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




On 9 June 2011 16:30, Roberto Ierusalimschy <roberto@inf.puc-rio.br> 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

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

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.)

-- Roberto


The first case I understand and it is just warning that it's code analysis has determined that a signed overflow (which is defined is gcc) does not happen and therefore it is preforming optimisations based on this assumption. Whilst the second case I am not sure why it is flagging it. To remove the first you could use an unsigned type in the loop, assuming that it is never a negative value which would translate to an unsigned wrap.