Marek Polacek <pola...@redhat.com>:
> On Fri, Feb 27, 2015 at 11:53:14AM -0800, Martin Uecker wrote:
> > 
> > I tested Marek's proposed change and it works correctly,
> > i.e. arrays which are not part of a struct are now
> > instrumented when accessed through a pointer. This also
> > means that the following case is diagnosed (correctly)
> > as undefined behaviour as pointed out by Richard:
> > 
> > int
> > main (void)
> > {
> >   int *t = (int *) __builtin_malloc (sizeof (int) * 9);
> >   int (*a)[3][3] = (int (*)[3][3])t;
> >   (*a)[0][9] = 1;
> > }
> > 
> > 
> > I also wanted arrays which are the last elements of a
> > struct which are not flexible-array members instrumented 
> > correctly. So I added -fsantitize=bounds-strict which does
> > this. It seems to do instrumentation similar to clang 
> > with -fsanitize=bounds.
> > 
> > Comments?
>  
> Thanks for working on it.  So I think we should split this patch in
> two; one part is a bug fix (I've opened
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65280>) that could go
> into gcc 5 - that is, apply my fix along with test cases covering the
> new cases, and the second part is an addition of a new option for
> strict bounds checking - I'm afraid this part has to wait for gcc 6.
> 
> I can take care of the first part and let you do the second part, which I
> could review.  Does that sound ok to you?

Thank you Marek! Sounds good to me.

Martin

Reply via email to