Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | jgk@panix.com (Joe keane) |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: i think i found |
| Date | 2012-03-14 23:34 +0000 |
| Organization | Public Access Networks Corp. |
| Message-ID | <jjr9th$f7d$1@reader1.panix.com> (permalink) |
| References | <jje9kd$d14$1@reader1.panix.com> <lnipiaewcj.fsf@nuthaus.mib.org> <jjoak2$qkr$1@reader1.panix.com> <lnk42ocf5l.fsf@nuthaus.mib.org> |
In article <lnk42ocf5l.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>The array subscript operation is defined in terms of pointer
>arithmetic; E1[E2] is by definition identical to (*((E1)+(E2))).
What is 'array subscript'?
An array type is contiguous. What does that mean?
int f(int t)
{
int a[3];
int *p;
p = a;
++p;
*p = 1;
}
As we expect, this stores in a consistent location.
An array of arrays is contiguous. It doesn't say only the last
dimension is contiguous, all of them are. So then the whole thing is.
And we have 'sizeof' to prove it.
int g(int t)
{
int b[4][5];
int *p;
p = *a;
p += 4;
*p = 4;
p += 2;
*p = 6;
}
If it breaks on the second one, then the array is not 'contiguous'.
The compiler can't change it to 'int b[4][8];' because that's not
'contiguous' the way the programmer wanted.
I'm just using an 'int *' here. It has to work the same as any other
'int *', pointing to the stack, from malloc, or whatever. I don't think
it can 'remember' a bunch of extra stuff.
>It follows from that that your example's behavior is undefined.
unclear
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
i think i found jgk@panix.com (Joe keane) - 2012-03-10 01:09 +0000
Re: i think i found Ian Collins <ian-news@hotmail.com> - 2012-03-10 14:23 +1300
Re: i think i found nick_keighley_nospam@hotmail.com - 2012-03-10 03:13 -0800
Re: i think i found Barry Schwarz <schwarz45@yahoo.com> - 2012-03-10 09:17 -0800
Re: i think i found pete <pfiland@mindspring.com> - 2012-03-10 19:22 -0500
Re: i think i found James Kuyper <jameskuyper@verizon.net> - 2012-03-10 20:14 -0500
Re: i think i found pete <pfiland@mindspring.com> - 2012-03-10 21:59 -0500
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-12 17:29 +0000
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-11 19:35 +0000
Re: i think i found Keith Thompson <kst-u@mib.org> - 2012-03-11 13:06 -0700
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-13 20:27 +0000
Re: i think i found Keith Thompson <kst-u@mib.org> - 2012-03-13 15:25 -0700
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-14 23:34 +0000
Re: i think i found Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-03-14 20:38 -0400
Re: i think i found Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-15 18:03 -0700
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-17 17:34 +0000
Re: i think i found Keith Thompson <kst-u@mib.org> - 2012-03-17 18:02 -0700
Re: i think i found jgk@panix.com (Joe keane) - 2012-03-19 15:41 +0000
Re: i think i found Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-21 05:52 -0700
csiph-web