Re: Infinite loop in dcraw with current GCC versions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27 February 2015 at 20:02,  <dcoffin@xxxxxxxxxxxxxxxxxx> wrote:
> Manuel,
>
>      There is no "undefined behavior" here.  K&R defined it
> very clearly:  Arrays are pointers, and square brackets are
> syntactic sugar for pointer arithmetic and dereferencing:
>
>         cam_xyz[i][j]  vs.  *(cam_xyz + (i)*3 + (j))

Unfortunately, this is simply not true for ISO C, which is the
language that most compilers implement nowadays. And it is easy to
check for yourself:

test.c:445:27: error: incompatible types when assigning to type
'double[3]' from type 'double'
  *(cam_xyz + (0)*3 + (j)) = table[i].trans[j] / 10000.0;
                           ^

See also the first answer to
http://stackoverflow.com/questions/25139579/2d-array-indexing-undefined-behavior,
which seems correct, AFAIU.

Neither can you do: **(cam_xyz + (0)*3 + (j)), because cam_xyz has
type 'double (*)[3]' thus **(cam_xyz + 2) is referencing
cam_xyz[2][0].

Cheers,

Manuel.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux