Array Notation doesn't work with -Ox x>0 for me

Array Notation doesn't work with -Ox x>0 for me

Hi,I try to make use of the new Array Notation to simplify/vectorize my code. However, it seems that it works as expected only if I use -O0.
Let me show a very simple C code and its output that illustrates the problem. I create an array with some values, copy it to a new array and finally I dump both arrays to screen:

[csharp]#include 

#define N 4

int main(void){

	int i,j;

	int c0[N][N],c1[N][N];

	c0[:][:] = 0;
	c0[1:2][1:2] = 1;

	c1[:][:] = c0[:][:];

	for(i=0;iIf I compile the above code with "icc -O0 test.c" the output is
   0   0   0   0
   0   1   1   0
   0   1   1   0
   0   0   0   0

   0   0   0   0
   0   1   1   0
   0   1   1   0
   0   0   0   0

as I expect, while if I compile it with"icc -O3 test.c" (or -O1 or -O2) the output is different:

   0   0   0   0
   0   1   1   0
   0   1   1   0
   0   0   0   0

   1   1   1   1
   1   1   1   1
   1   1   1   1
   1   1   1   1

I tried it with float arrays instead of int, with different sizes, etc. Similar results.What am I doing wrong? Is there an extra compile option or an extra line I have to insert into my code that I'm nor aware of?Thanks for your help.

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Sorry, I forgot to mention that my compiler version is I think the most recent: 12.0.0

This might be a bug. I'll look into it and get back to you.

This problem is resolve with the latest Composer XE product update 1.

Leave a Comment

Please sign in to add a comment. Not a member? Join today