This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Richard Biener <rguenther at suse dot de>, Jeff Law <law at redhat dot com>
- Date: Mon, 16 Jun 2014 13:23:04 +0200
- Subject: Re: [PATCH] Implement -fsanitize=bounds and internal calls in FEs
- Authentication-results: sourceware.org; auth=none
- References: <20140616103907 dot GD17965 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Jun 16, 2014 at 12:39:07PM +0200, Marek Polacek wrote:
> Jason/Joseph, could you please look at the C++/C FE parts?
As mentioned on IRC, you need to differentiate between taking address
and not taking address.
struct S { int a; int b; } s[4], *t;
int *a, *b, *c;
void *d;
int e[4][4];
void
foo ()
{
t = &s[4]; // Should be fine
a = &s[4].a; // Error
b = &s[4].b; // Error
d = &e[4]; // Should be fine
c = &e[4][0]; // Error
}
So, supposedly when e.g. in cp_genericize_r, for ADDR_EXPR <ARRAY_REF>
allow off-by-one, for all other ARRAY_REFs (e.g. those not appearing
inside of ADDR_EXPR, or not directly inside of ADDR_EXPR, e.g. with
COMPONENT_REF or another ARRAY_REF in between) disallow off-by-one.
Jakub