[Bug tree-optimization/82494] UBSAN in gcc/tree-data-ref.c:3427:16: runtime error: signed integer overflow: 131072 * -131072 cannot be represented in type 'int'

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 3 07:56:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82494

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
I commented in the dup:

This code hasn't been fixed to avoid overflows and generally expects to operate
with infinite precision integers ... (you know, 32/64bits will be enough -
really!).

Fixing requires overhauling all of the API and data structures in dependence
analysis and finding a suitable representation for "infinite precision
integers".
Note that most of the APIs do not have a well-defined failure mode so bailing
out isn't easy either.

Using GMP is very likely prohibitly expensive not only due to its lack of
optimizing the small-precision case.  OTOH we are using it from niter analysis
already.  Evaluating ISL ints (isl/val.h when configured to not use GMP) might
be worth, as well as maybe looking at including (patched?) mini-gmp (not sure
if that plays well with linking against real gmp, but eventually mpfr plays
well enough with mini-gmp and doesn't get too slow).

Note the HWIs are less likely a problem than the ints currently used for
lambda vectors/matrices.

Note that simply silencing UBSAN by using unsigned arithmetic will simply
silence it, not avoiding wrong-code issues that might be latent there.


More information about the Gcc-bugs mailing list