This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/42711] New: the increment(++) or decrement(--) operators is wrong for short index of array


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]