questionable checks for flexible array members in c-ubsan.c and tree-vrp.c (was: Re: array bounds, sanitizer, safe programming, and cilk array notation)

2015-02-23 Thread Martin Uecker
Martin Uecker : > Marek Polacek : > > > > void foo(int (*x)[4]) > > > { > > > (*x)[4] = 5;// warning > > > } > > > > This is detected by -fsanitize=object-size, turned on by default in > > -fsanitize=undefined. Since it makes use of __builtin_object_size, > > it is necessary to compile w

Re: array bounds, sanitizer, safe programming, and cilk array notation

2015-02-23 Thread Joseph Myers
On Sat, 21 Feb 2015, Marek Polacek wrote: > option that detects a particular UB. Or say that a particular UB is a > compile-time error (e.g. "declaring a function at block scope with an explicit > storage-class specifier other than extern"). That one is already a hard error for cases such as sta

Re: array bounds, sanitizer, safe programming, and cilk array notation

2015-02-21 Thread Martin Uecker
Marek Polacek : > Sorry for late reply - I've found this in my inbox only today. > > On Mon, Jan 26, 2015 at 11:53:59AM -0800, Martin Uecker wrote: > > > Finally, what is missing is a way to diagnose problems inside > > the called functions. -Warray-bounds=2 (with my recently > > accepted patch

Re: array bounds, sanitizer, safe programming, and cilk array notation

2015-02-21 Thread Marek Polacek
Sorry for late reply. On Tue, Jan 27, 2015 at 12:07:58AM +, Joseph Myers wrote: > On Mon, 26 Jan 2015, Martin Uecker wrote: > > > extern void bar2(int (*x)[5]); > > > int c = 4; > > int y[c]; > > > bar2(&y); // not diagnosed (found by asan) > > This is the undefined behav

Re: array bounds, sanitizer, safe programming, and cilk array notation

2015-02-21 Thread Marek Polacek
Sorry for late reply - I've found this in my inbox only today. On Mon, Jan 26, 2015 at 11:53:59AM -0800, Martin Uecker wrote: > > Hi all, > > I am writing numerical code, so I am trying to make the use > of arrays in C (with gcc) suck a bit less. In general, the long term > goal would be to hav

Re: array bounds, sanitizer, safe programming, and cilk array notation

2015-01-26 Thread Joseph Myers
On Mon, 26 Jan 2015, Martin Uecker wrote: > extern void bar2(int (*x)[5]); > int c = 4; > int y[c]; > bar2(&y); // not diagnosed (found by asan) This is the undefined behavior "If the two array types are used in a context which requires them to be compatible, it is unde

array bounds, sanitizer, safe programming, and cilk array notation

2015-01-26 Thread Martin Uecker
Hi all, I am writing numerical code, so I am trying to make the use of arrays in C (with gcc) suck a bit less. In general, the long term goal would be to have either a compile-time warning or the possibility to get a run-time error if one writes beyond the end of an array as specified by its ty