Dominique Pellé wrote:

> Bram Moolenaar <[email protected]> wrote:
> 
> > Axel Bender wrote:
> >
> >> Windows 7 64-bit, MinGw 64
> >>
> >>
> >> >>>CONSOLE<<<
> >>
> >> gcc -c -Iproto -DWIN32 -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 
> >> -DHAVE_PATHDEF -DFEAT_BIG -DMS_WIN64 -DHAVE_GETTEXT -DHAVE_LOCALE_H 
> >> -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_CHANNEL -DFEAT_MBYTE 
> >> -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -pipe -march=x86-64 -Wall 
> >> -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python32.dll\" 
> >> -O3 -fomit-frame-pointer -freg-struct-return -s getchar.c -o 
> >> objx86-64/getchar.o
> >>
> >> getchar.c: In function 'check_map':
> >> getchar.c:5212:7: warning: assuming signed overflow does not occur when 
> >> assuming that (X - c) <= X is always true [-Wstrict-overflow]
> >>     if (len > mp->m_keylen - 3)
> >>        ^
> >>
> >> >>>GUI<<<
> >>
> >> gcc -c -Iproto -DWIN32 -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 
> >> -DHAVE_PATHDEF -DFEAT_BIG -DMS_WIN64 -DHAVE_GETTEXT -DHAVE_LOCALE_H 
> >> -DDYNAMIC_GETTEXT -DFEAT_CSCOPE -DFEAT_CHANNEL -DFEAT_GUI_W32 
> >> -DFEAT_CLIPBOARD -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME 
> >> -DDYNAMIC_ICONV -pipe -march=x86-64 -Wall -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 
> >> -DDYNAMIC_PYTHON3_DLL=\"python32.dll\" -DFEAT_XPM_W32 -I xpm/x64/include 
> >> -I xpm/x64/../include -O3 -fomit-frame-pointer -freg-struct-return -s 
> >> getchar.c -o gobjx86-64/getchar.o
> >>
> >> getchar.c: In function 'check_map':
> >> getchar.c:5212:7: warning: assuming signed overflow does not occur when 
> >> assuming that (X - c) <= X is always true [-Wstrict-overflow]
> >>     if (len > mp->m_keylen - 3)
> >>        ^
> >
> > This was mentioned before.  There is nothing wrong with this code.  I
> > rather blame the compiler.  I also don't see a good way to avoid the
> > warning.  Someone suggested casting to unsigned, but that actually
> > breaks it.
> 
> I was not thrilled about the unsigned cast, but how did it break it?
> 
>   if ((unsigned)len > (unsigned)mp->m_keylen - 3U)
> 
> Even if m_keylen was say 2, then it would behave as
> without the cast, as it would compare len with a very
> big number. I think it works, but does not win a beauty price.

Am I missing something?  Suppose mp->m_keylen is zero.  Then subtracting
3 from it results in -3.  If len is 1, the result is TRUE.

If we use the unsigned cast then subtracting 3 from zero results in a big
number, if len is 1 the result is FALSE.

-- 
If cars evolved at the same rate as computers have, they'd cost five euro, 
run for a year on a couple of liters of petrol, and explode once a day.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui