2016-02-26 12:34 GMT+03:00 Mike Williams <[email protected]>: > On 24/02/2016 23:21, Nikolay Aleksandrovich Pavlov wrote: >> >> 2016-02-22 19:57 GMT+03:00 Bram Moolenaar <[email protected]>: >>> >>> This one too. >>> >>>> [...] >>>> os_win32.c: In function 'read_console_input.constprop.22': >>>> os_win32.c:299:28: warning: array subscript is above array bounds >>>> [-Warray-bounds] >>>> s_irCache[i] = s_irCache[i + 1]; >>>> ^ >>> >>> >>> Not sure how to fix this. Or even if this is a real problem. >> >> >> I do not know whether this is a real problem, but such things are best >> written with memmove: >> >> memmove(s_irCache + head, s_irCache + head + 1, (size_t) (tail - >> head) * sizeof(s_irCache[0])); > > > The warning will be because ultimately i is limited by s_dwMax which is > based on a value returned from ReadConsoleInputW() and the compiler cannot > tell if this will be larger that IRSIZE although we know it from the API > doc. Limiting the range of s_dwMax with something like > > s_dwMax = min(dwEvents, IRSIZE); > > may kill the warning without the code gymnastics above.
This is not code gymnastics. If one wants to shift an array he should use memmove() because this is exactly the purpose of this function, also slightly less code then a cycle. This should also run faster, unless compiler was able to optimize cycle to the same code as memmove() (which should be rather likely given how common this pattern is). > > 2ps worth. TTFN > > Mike > -- > The face of a child can say it all, especially the mouth part of the face. > > -- > -- > 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. -- -- 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.
