Re: Once again pointer to first element vs pointer to array cast
by pete <pfiland@[EMAIL PROTECTED]
>
May 7, 2008 at 07:19 AM
Szabolcs Borsanyi wrote:
> I know that this topic has been discussed a lot, still I'd appreciate
> a clear cut (and correct) answer:
> I pass a multidimensional array to a function, which is defined as
> int f(int a[10][10])
> {
> int *b=(void*)a;
> int *c=a[0];
> /*...*/
> }
> Now the questions come:
> - Is it guaranteed that b and c points to the same object (or is this
> implementation defined)?
This is the only guarantee you have with that kind of conversion:
N869
6.3.2.3 Pointers
[#1] A pointer to void may be converted to or from a pointer
to any incomplete or object type. A pointer to any
incomplete or object type may be converted to a pointer to
void and back again; the result shall compare equal to the
original pointer.
> - Is it always true that a[1][1] refers to the same object as c[11] ?
> (There is no hole)
c[11] is undefined.
> - Does dereferencing b violate any aliasing rule?
--
pete