This is the mail archive of the gcc@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: bug or idiosyncrasy?


On 17 August 2012 08:25, Andrew Pinski wrote:
> On Fri, Aug 17, 2012 at 12:15 AM, Ulrich Drepper <drepper@gmail.com> wrote:
>> Compiling the following code with D defined works.  Leave it out (and
>> remove the extra dimension which has no influence on the data layout
>> etc) and it compiles.  Is this correct?  Why wouldn't a simple use of
>> an array parameter be sufficient?
>
> It looks like the decaying to a pointer in the function argument is
> what is causing the issues.
>
> See  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24666 for other related issues.

Those are real bugs, but in Ulrich's case the array to pointer
conversion is required and I don't believe it's a bug.  f(int arr[10])
has a parameter of type "array of int", so [dcl.fct]/5 says it decays
to "pointer to int" i.e. the signature is f(int*) and so it's not
possible to iterate over the parameter with a range-based for loop.

In the working case the parameter has type "array of array of int"
which decays to "pointer to array of int" and so the signature is
f(int (*)[10]) and dereferencing the parameter gives an array type,
which can be iterated over.


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