Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

How should "x = a[x]++" be compiled ?

$
0
0

It seems I either have forgotten how C works, or ICC has a very basic (and thus very serious bug).

When compiling   x = a[x]++;   ICC does not increment the array value, while GCC does (as it should).

I am using the latest ICC (14.0.2). This toy code shows this:

#include <stdio.h>

int main(void)

{

    int a[1] = {5}, i = 0;

    i = a[i]++;

    printf("%d %d\n", i, a[0]);

    return 0;

}


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>