public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Geoff Keating <geoffk@cygnus.com>
To: Kamil Iskra <kamil@wins.uva.nl>
Cc: gcc@gcc.gnu.org
Subject: Re: Array out of bounds warning
Date: Wed, 02 Aug 2000 18:12:00 -0000	[thread overview]
Message-ID: <jmya2fb10u.fsf@envy.cygnus.com> (raw)
In-Reply-To: <Pine.LNX.4.10.10008022217510.1359-100000@bubu.home>

Kamil Iskra <kamil@wins.uva.nl> writes:

> On Mon, 31 Jul 2000, Jeffrey A Law wrote:
> 
> >   > int a[10];
> >   > a[10] = 17;
> [snip]
> > The next question in my mind is how often do we get false hits on the
> > warning.
> 
> I've been wondering: what will the proposed patch do for n-dimensional
> arrays, say:
> 
> int a[10][10];
> a[0][10]=17;
> 
> I think right now the code will generate a warning, but is this what we
> want?
> 
> I'm not entirely sure whether the standard does allow such a construction,
> but surely it has a well defined meaning, given that the memory layout of
> arrays is precisely defined in the standard. I've seen such a code only
> yesterday, where it was used for speed reasons, so it's probably not an
> uncommon trick.

The behaviour is rendered undefined by the ISO C standard.  This is
precisely so that compilers can do bounds-checking on references like
these.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

  reply	other threads:[~2000-08-02 18:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-30 14:16 Falk Hueffner
2000-07-31  7:11 ` Jeffrey A Law
2000-07-31 11:19   ` Falk Hueffner
2000-08-02 14:59   ` Kamil Iskra
2000-08-02 18:12     ` Geoff Keating [this message]
2000-08-03  0:59       ` Kamil Iskra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jmya2fb10u.fsf@envy.cygnus.com \
    --to=geoffk@cygnus.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kamil@wins.uva.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).