Re: Infinite loop in dcraw with current GCC versions

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

 



Actually, the question that I was unsure about and I could not find a
ready answer in the standard is whether one can use ((double
*)(&cam_xyz[0][0]))[j] to address the whole multidimensional array.

No, that's undefined. The relevant text is in section 6.5.6,
paragraph 8 of the C11 standard and summarized in Annex J.2,
Undefined Behavior with a clarifying example like so:

  An array subscript is out of range, even if an object is
  apparently accessible with the given subscript (as in the
  lvalue expression a[1][7] given the declaration int a[4][5])
  (6.5.6).

> This also
> raises the question of whether is valid to initialize a
> multidimensional array with memset as memset(&cam_xyz[0][0], 0,
> sizeof(cam_xyz)).

Using memset, memcpy, and memove on any object, including an
array, is valid because all objects may be accessed via lvalues
of unsigned char and that's just what the memxxx functions are
specified to do.

Martin




[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