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.
Please check the above analysis, my knowledge of C language syntax is
half-forgotten, and it was sketchy to begin with. In particular I'm
assuming that the (int) typecast will sign-extend or zero-extend the
char value to an int, but I'm not at all sure that the compiler won't
instead take as many bytes as can make up an int from the address
pointed to.
Best regards,
Tony.
--
A reading from the Book of Armaments, Chapter 4, Verses 16 to 20:
Then did he raise on high the Holy Hand Grenade of Antioch, saying,
"Bless this, O Lord, that with it thou mayst blow thine enemies to tiny
bits, in thy mercy." And the people did rejoice and did feast upon the
lambs and toads and tree-sloths and fruit-bats and orangutans and
breakfast cereals ... Now did the Lord say, "First thou pullest the
Holy Pin. Then thou must count to three. Three shall be the number of
the counting and the number of the counting shall be three. Four shalt
thou not count, neither shalt thou count two, excepting that thou then
proceedeth to three. Five is right out. Once the number three, being
the number of the counting, be reached, then lobbest thou the Holy Hand
Grenade in the direction of thine foe, who, being naughty in my sight,
shall snuff it."
-- Monty Python, "Monty Python and the Holy Grail"
--
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