Kaz Kylheku <> writes:
> On Feb 13, 8:57Â*am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>> Kaz Kylheku <kkylh...@gmail.com> writes:
>> > On Feb 12, 9:56Â*am, "Tomás Ó hÉilidhe" <t...@lavabit.com> wrote:
>> >> Keith Thompson:
>>
>> >> > An expression of array type is converted to a pointer. Â*There has to
>> >> > be something to convert in the first place.
>>
>> >> Â* Â* Yes but an array type isn't a value -- which is the very reason why
>> >> arrays decay to a pointer to their first element, so that we can actually
>> >> get a value out of them.
>>
>> > And what value will you get from a nonexistent, imaginary array, after
>> > decaying it to a pointer to a nonexistent first element?
>>
>> You would get exactly the pointer the OP wanted -- to the int
>> immediately following the 1D array.
>
> Of course, you would only get that if the implementation didn't throw
> a diagnostic in your face and stop the program first.
Do you get one? gcc is silent about
int array[5] = {0};
int *pe1 = *(&array + 1);
even with
-std=c89 -pedantic -pedantic -W -Wall -Wextra -Wformat-nonliteral
-Wcast-align -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes
-Winline -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wconversion
-Wwrite-strings -ffloat-store
in effect!
>>Â*I say "would" because I think the
>> example is UB, though only because the utility of applying * to an
>> array pointer (pointing "one past" a whole array) was missed when
>> drawing up the rule about applying * to these "one past" pointers.
>
> Exactly. Correctness is not just about getting the right value, but
> about how you got it. What is 64/16? Ah, numerator 6 cancels the
> denominator 6 so we get 4/1 = 4.
I agree, but do you really think the method _is_ flawed? Both your
remarks have

appended which makes me think you are not very
serious your objections.
If the standard says "X is UB" (as it does in this case, I think) we
are entitled to ask "why?". Is it because the construct might be
unimplementable on some architectures (that would be my reason for
outlawing the construction of a "one before" pointer), or is it
because it constrains the implementation too much (the reason for
having an unspecified evaluation order)? What is the reasoning being
outlawing the above?
--
Ben.