Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > Re: Once again ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 26097 of 26972
Post > Topic >>

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
 




 8 Posts in Topic:
Once again pointer to first element vs pointer to array cast to
Szabolcs Borsanyi <bor  2008-05-06 23:46:56 
Re: Once again pointer to first element vs pointer to array cast
pete <pfiland@[EMAIL P  2008-05-07 07:19:33 
Re: Once again pointer to first element vs pointer to array cast
Barry Schwarz <schwarz  2008-05-07 22:40:39 
Re: Once again pointer to first element vs pointer to array cast
David Thompson <dave.t  2008-05-19 03:59:52 
Re: Once again pointer to first element vs pointer to array cast
Szabolcs Borsanyi <bor  2008-05-23 00:14:42 
Re: Once again pointer to first element vs pointer to array cast
Szabolcs Borsanyi <s.b  2008-05-23 08:59:14 
Re: Once again pointer to first element vs pointer to array cast
Ben Bacarisse <ben.use  2008-05-23 12:03:50 
Re: Once again pointer to first element vs pointer to array cast
Ben Bacarisse <ben.use  2008-05-23 12:06:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 16:13:25 CDT 2008.