From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: Robustify REAL_MODE_FORMAT
Date: Thu, 29 Oct 2015 15:33:00 -0000 [thread overview]
Message-ID: <87eggdu1z4.fsf@e105548-lin.cambridge.arm.com> (raw)
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.
OK to install?
Thanks,
Richard
gcc/
* real.h (REAL_MODE_FORMAT): Abort if the mode isn't a
SCALAR_FLOAT_MODE_P.
diff --git a/gcc/real.h b/gcc/real.h
index e65b526..d3b14e5 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) \
next reply other threads:[~2015-10-29 15:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 15:33 Richard Sandiford [this message]
2015-10-29 15:37 ` Bernd Schmidt
2015-10-29 16:29 ` Richard Biener
2015-10-29 16:33 ` Richard Sandiford
2015-10-30 9:02 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eggdu1z4.fsf@e105548-lin.cambridge.arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).