K&R defined this very clearly: Arrays are pointers. Square brackets are syntactic sugar for pointer arithmetic and dereferencing: cam_xyz[i][j] vs. *(cam_xyz + (i)*3 + (j)) Whether or not the compiler optimizes a loop out of existence, it must interpret the contents of the loop no differently. Fortunately, GCC 4.9 has no problem abiding this rule. Dave Coffin 2/27/2015 On Fri, Feb 27, 2015 at 06:02:51PM +0100, conchur@xxxxxx wrote: > > This sounds like a compiler bug to me. A statement > > of the form: > > > > for (i=0; i < 12; i++) { > > <code that doesn't change "i"> > > } > > > > should never generate an infinite loop. > > As seen in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54136#c5 this > is hiding something important: > > > double cam_xyz[4][3]; > > The code tries to access it like this: > > > cam_xyz[0][j] = table[i].trans[j] / 10000.0; > > > And this is the problem with your code. It just does something > undefined and happens to get some defined behavior. This is why > GCC developers marked this problem as invalid and told that the > code is broken [1]. > > > [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54136#c5