Tony Mechelynck wrote:
> version.c: In function ‘intro_message’:
> version.c:1273:7: warning: array subscript is above array bounds
>
> The incriminated line is the test on mediumVersion[4] near the middle of
>>
>> if (add_version)
>> {
>> STRCPY(vers, mediumVersion);
>> if (highest_patch())
>> {
>> /* Check for 9.9x or 9.9xx, alpha/beta version */
>> if (isalpha((int)mediumVersion[3]))
>> {
>> if (isalpha((int)mediumVersion[4]))
>> sprintf((char *)vers + 5, ".%d%s", highest_patch(),
>> mediumVersion +
>> 5);
>> else
>> sprintf((char *)vers + 4, ".%d%s", highest_patch(),
>> mediumVersion +
>> 4);
>> }
>> else
>> sprintf((char *)vers + 3, ".%d", highest_patch());
>> }
>> col += (int)STRLEN(vers);
>> }
>
> in this case (see version.c:31 and version.h:38) mediumVersion is "7.3", so
> IIUC mediumVersion[3] is the end-of-string null and mediumVersion[4] is
> whatever comes after that in memory. But since a null byte is not
> alphabetic, isalpha((int)mediumVersion[3]) is FALSE and the warning is in
> dead code.
Hi Tony
You're right. Code inside the if (isalpha((int)mediumVersion[3]))
would never be executed with mediumVersion being "7.3". So
there is no bug.
However, the warning is not pleasant. I don't see the warning
myself by the way using gcc-4.4.3.
Attached patch should pacify your compiler.
-- Dominique.
--
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
diff -r fde086181841 src/version.c
--- a/src/version.c Mon Aug 16 22:34:29 2010 +0200
+++ b/src/version.c Wed Aug 18 07:30:06 2010 +0200
@@ -1266,9 +1266,9 @@
if (highest_patch())
{
/* Check for 9.9x or 9.9xx, alpha/beta version */
- if (isalpha((int)mediumVersion[3]))
+ if (isalpha((int)vers[3]))
{
- if (isalpha((int)mediumVersion[4]))
+ if (isalpha((int)vers[4]))
sprintf((char *)vers + 5, ".%d%s", highest_patch(),
mediumVersion + 5);
else