This is the mail archive of the
mailing list for the GCC project.
Re: Bounded Array Type?
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Martin Uecker <uecker at eecs dot berkeley dot edu>
- Cc: <gcc at gcc dot gnu dot org>, Florian Weimer <fweimer at redhat dot com>, James Nelson <retrobanana dot jn at gmail dot com>
- Date: Thu, 23 Oct 2014 15:17:09 +0000
- Subject: Re: Bounded Array Type?
- Authentication-results: sourceware.org; auth=none
- References: <20141022221244 dot 27447064 at lemur>
On Wed, 22 Oct 2014, Martin Uecker wrote:
> Sorry for bringing this up again, but this could work:
> void foo(int x, int (*s)[x])
> (*s)[x] = 1; // <- undefined behaviour
Yes, I believe that's undefined (even if the array is part of a larger
object, as the same principle as "An array subscript is out of range, even
if an object is apparently accessible with the given subscript (as in the
lvalue expression a given the declaration int a) (6.5.6)."
(Annex J) applies).
Joseph S. Myers