Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18842

Re: i think i found

From jgk@panix.com (Joe keane)
Newsgroups comp.lang.c
Subject Re: i think i found
Date 2012-03-17 17:34 +0000
Organization Public Access Networks Corp.
Message-ID <jk2i03$gub$1@reader1.panix.com> (permalink)
References <jje9kd$d14$1@reader1.panix.com> <lnk42ocf5l.fsf@nuthaus.mib.org> <jjr9th$f7d$1@reader1.panix.com> <kfn7gyll5m7.fsf@x-alumni2.alumni.caltech.edu>

Show all headers | View raw


In article <kfn7gyll5m7.fsf@x-alumni2.alumni.caltech.edu>,
Tim Rentsch  <txr@alumni.caltech.edu> wrote:
>If you care, an assignment (or initialization) like
>
>    int *p = (int*) &b;
>
>is more likely to work as you expect (ie, and be defined
>behavior) for the "cross-subarray-bounds" indexing like
>that shown in the example.

I debated how to write this.

Is it possible the following are different:

    p = (int *) &b;
    p = (int *) &b[0];
    p = /int */ &b[0][0];

Maybe some work and others don't?

It seems like we're just guessing here.

I try to follow the standard, even the parts that contradict the other
parts.

I've been programming C for a long time, and i just 'knew' this is
perfectly valid C (for some reason), so i was a bit shocked.

I would just say, for 'int *' not 'int (*)[N]', we can increment it,
valid as long as you're within the *main* array, that it is whatever it
is declared as, global, or on the stack, or from malloc, and not just in
the first 'row', it is contiguous in all dimensions, and we should have
&a[1][0] == &a[0][5], and it is nonsensical for them to work different.

That seems like a basic property, first, they are contiguous, and second,
you can actually use that in your code.

If the standard doesn't say so, or says it is and it isn't at the same
time, i think it's defective.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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