This is the mail archive of the
mailing list for the GCC project.
Re: Infinite loop in dcraw with current GCC versions
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: dcoffin at shell dot cybercom dot net, "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>, Conchúr Navid <conchur at web dot de>, Sven Eckelmann <sven at narfation dot org>, René Rebe ExactCODE <rene at exactcode dot com>
- Date: Mon, 2 Mar 2015 12:08:19 +0100
- Subject: Re: Infinite loop in dcraw with current GCC versions
- Authentication-results: sourceware.org; auth=none
- References: <CAESRpQDZs=EZTAj7bO5Dn8d=M8p8MuN7_s__XNatnL2BWgs9wA at mail dot gmail dot com> <CAESRpQBx7V=O-pH5Ckvt=XpJHYyEwCyZGz1HQTByqdKftQC0MQ at mail dot gmail dot com> <20150227190206 dot GA6175 at shell dot cybercom dot net> <CAESRpQCCWVQGeWMByFFiX6MLoA-VxJ3AAp5u99VdOy7h8SsgQg at mail dot gmail dot com> <20150227204552 dot GA8916 at shell dot cybercom dot net> <CAESRpQAbO-6Zy3FBvR56NDiAGJg8CZYtSTUPLR5jud0baNHKHg at mail dot gmail dot com> <54F2FBA6 dot 1060308 at redhat dot com>
On 1 March 2015 at 12:44, Andrew Haley <firstname.lastname@example.org> wrote:
> On 28/02/15 16:27, Manuel López-Ibáñez wrote:
>> On the other hand,
>> &cam_xyz should have type 'double *', and the standard does say
>> that the data is contiguously allocated, yet the c-faq says that
>> ((double *)(&cam_xyz))[j] "is not in strict conformance with the
>> ANSI C Standard; according to an official interpretation"
>> (http://c-faq.com/aryptr/ary2dfunc2.html), although without a
>> reference to the standard, I have no idea what that means.
> Therefore the result of the inner
> is a one-dimensional array. You have no permission to dereference
> beyond the end of that array, and any attempt to do so is UB.
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))[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.