From: Richard Sandiford Date: Fri, 30 Oct 2015 13:42:27 +0000 (+0000) Subject: Robustify REAL_MODE_FORMAT X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5e09aa0aaec24109949afabb20b813e9096905f;p=gcc.git Robustify REAL_MODE_FORMAT Make sure that REAL_MODE_FORMAT aborts if it is passed an invalid mode, rather than stepping beyond the bounds of an array. It turned out that some code was passing non-float modes to the real.h routines. Tested on x86_64-linux-gnu, arm-linux-gnueabi and aarch64-linux-gnu. gcc/ * real.h (REAL_MODE_FORMAT): Abort if the mode isn't a SCALAR_FLOAT_MODE_P. From-SVN: r229579 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7178c5aeec3..26f9a375257 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-10-30 Richard Sandiford + + * real.h (REAL_MODE_FORMAT): Abort if the mode isn't a + SCALAR_FLOAT_MODE_P. + 2015-10-30 Alan Lawrence * tree-sra.c (scalarizable_type_p): Comment variable-length arrays. diff --git a/gcc/real.h b/gcc/real.h index e65b5263e11..d3b14e5b4f8 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -167,7 +167,9 @@ extern const struct real_format * (real_format_for_mode[DECIMAL_FLOAT_MODE_P (MODE) \ ? (((MODE) - MIN_MODE_DECIMAL_FLOAT) \ + (MAX_MODE_FLOAT - MIN_MODE_FLOAT + 1)) \ - : ((MODE) - MIN_MODE_FLOAT)]) + : GET_MODE_CLASS (MODE) == MODE_FLOAT \ + ? ((MODE) - MIN_MODE_FLOAT) \ + : (gcc_unreachable (), 0)]) #define FLOAT_MODE_FORMAT(MODE) \ (REAL_MODE_FORMAT (SCALAR_FLOAT_MODE_P (MODE)? (MODE) \