This is the mail archive of the
mailing list for the GCC project.
Bounded Array Type?
- From: Martin Uecker <uecker at eecs dot berkeley dot edu>
- To: gcc at gcc dot gnu dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Florian Weimer <fweimer at redhat dot com>, James Nelson <retrobanana dot jn at gmail dot com>
- Date: Wed, 22 Oct 2014 22:12:44 -0700
- Subject: Bounded Array Type?
- Authentication-results: sourceware.org; auth=none
Sorry for bringing this up again, but this could work:
void foo(int x, int (*s)[x])
(*s)[x] = 1; // <- undefined behaviour
Such an access beyond the specified length means that either
1. the array is accessed out-of-bounds or
2. was accessed using an incompatible pointer
and a compiler would be allowed to catch this.