[PATCH] Fix up __builtin_alloca_with_align (0, ...) folding (PR sanitizer/91707)

Richard Biener rguenther@suse.de
Tue Sep 24 13:10:00 GMT 2019


On Tue, 24 Sep 2019, Jakub Jelinek wrote:

> On Tue, Sep 24, 2019 at 01:15:46PM +0200, Richard Biener wrote:
> > > build_array_type_nelts is only meaningful for non-zero number of elements,
> > > for 0 it creates weirdo arrays like char D.2358[0:18446744073709551615].
> > > The following patch uses in that case types like the C FE emits for
> > > zero-length array instead (i.e. char D.2358[0:] with forced 0 size).
> > > 
> > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > 
> > Not sure [0:-1] is actually the canonical zero-length array (and IIRC
> > what the C++ FE creates and what layout_type can lay out).  So why
> 
> You're right, patch withdrawn.
> 
> > not fix the sanitizers instead?
> 
> Well, the problem isn't in sanitizers, but jump threading and late warnings
> that are warning even about code specialized by jump threading.
> It could be indeed solved with __builtin_warning if we defer the late
> warnings and ignore them inside of sanitization report only paths (if we can
> detect them reliably, perhaps pass dominated by a failed ubsan or asan
> sanitization check), or by making jump threading not try to optimize the
> cold sanitization diagnostics parts.

Hmm yeah.

Note that in principle the domain could be signed so that the
-1 is more obvious.  Also [1:0] would be an equally valid empty
domain.  Not sure if that helps the specific jump-threading case, of 
course...

Richard.



More information about the Gcc-patches mailing list