This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/42711] New: the increment(++) or decrement(--) operators is wrong for short index of array
- From: "aonebeam at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jan 2010 16:11:34 -0000
- Subject: [Bug c/42711] New: the increment(++) or decrement(--) operators is wrong for short index of array
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following tests are made on solaris 5.10 platform.
This is the example of the decrement(--) for short index of array:
/*********************************************************/
#include <stdio.h>
int main()
{
int aryHuowq[3] = {0};
short nIndex = 2; /* nIndex is short */
aryHuowq[nIndex--] = nIndex + 1;
printf("array[%d] : %d\n", nIndex+1, aryHuowq[nIndex+1]);
return 0;
}
/*****************************************************************/
/* The result is "array[2] : 2", but it should be "array[2] : 3" */
/*****************************************************************/
If nIndex is type of int, then the result is "array[2] : 3".
--
Summary: the increment(++) or decrement(--) operators is wrong
for short index of array
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aonebeam at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42711