From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [ubsan PATCH] Fix bounds-2.c test with -fstack-protector-strong
Date: Wed, 23 Jul 2014 13:33:00 -0000 [thread overview]
Message-ID: <20140723132044.GE30336@redhat.com> (raw)
Jakub reported to me that bounds-2.c test fails with
-fstack-protector-strong -Os. The following hack fixes it.
Tested x86_64-linux, applying to trunk as obvious.
2014-07-23 Marek Polacek <polacek@redhat.com>
* c-c++-common/ubsan/bounds-2.c (fn4): Adjust to check the array size
in the structure.
diff --git gcc/testsuite/c-c++-common/ubsan/bounds-2.c gcc/testsuite/c-c++-common/ubsan/bounds-2.c
index 7ef71aa..73229dc 100644
--- gcc/testsuite/c-c++-common/ubsan/bounds-2.c
+++ gcc/testsuite/c-c++-common/ubsan/bounds-2.c
@@ -4,6 +4,7 @@
/* Test runtime errors. */
struct S { int a[10]; };
+struct T { int a[5]; int s[2]; };
int
foo_5 (void)
@@ -47,8 +48,9 @@ fn3 (void)
static void __attribute__ ((noinline, noclone))
fn4 (void)
{
- volatile int a[5];
- a[foo_5 ()] = 1;
+ struct T t;
+ asm ("" : : "r" (&t.a) : "memory");
+ t.a[foo_5 ()] = 1;
}
static void __attribute__ ((noinline, noclone))
Marek
reply other threads:[~2014-07-23 13:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140723132044.GE30336@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/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).