diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2015-10-30 13:42:27 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2015-10-30 13:42:27 +0000 |
commit | d5e09aa0aaec24109949afabb20b813e9096905f (patch) | |
tree | ea61f6c5d9733c823fab8c6df2bdd0114bcbfe15 /gcc/real.h | |
parent | 56517dda83af315590448610b4b6cd9d4f4d7527 (diff) | |
download | gcc-d5e09aa0aaec24109949afabb20b813e9096905f.zip gcc-d5e09aa0aaec24109949afabb20b813e9096905f.tar.gz gcc-d5e09aa0aaec24109949afabb20b813e9096905f.tar.bz2 |
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
Diffstat (limited to 'gcc/real.h')
-rw-r--r-- | gcc/real.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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) \ |