This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Infinite loop in dcraw with current GCC versions


On 03/02/2015 11:26 AM, Manuel López-Ibáñez wrote:
> On 2 March 2015 at 12:14, Andrew Haley <aph@redhat.com> wrote:
>> On 03/02/2015 11:08 AM, Manuel López-Ibáñez wrote:
>>> 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.
>>> The C-FAQ seems to suggest that one cannot, but it is not crystal
>>> clear in this respect.
>>
>> It may not be, but the passage I sent you is.
> 
> The way I read that passage is that *cam_xyz is of type double[3] and
> *(*cam_xyz) is of type 'double', but it doesn't say anything about
> dereferencing the pointer &(*(*cam_xyz)) beyond any limits.

Would you like me also to quote you the section of the standard which
says you cannot address beyond the end of an array?  That is not in
any doubt so I did not post it.

> 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)).

It does not because bytes are special: there is explicit language in
the standard which says that any object pointer may be converted to a
byte pointer, and that byte pointer may be used to address all of the
object.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]