This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix undefined behavior in x86_64 backend (PR target/61656)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Uros Bizjak <ubizjak at gmail dot com>, Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 11 Jul 2014 22:21:41 +0200
- Subject: [PATCH] Fix undefined behavior in x86_64 backend (PR target/61656)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
As mentioned in the PR, if bit_offset is not zero, subclasses array
may contain for unions more entries than classes array. We are going
to ignore the extra entries, because we only check the ones below words,
but as classes[words] and above is uninitialized, this triggers undefined
behavior. merge_classes seems to be a const function, so the patch should
not affect code generation in any way.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and
4.9.2?)?
2014-07-11 Jakub Jelinek <jakub@redhat.com>
PR target/61656
* config/i386/i386.c (classify_argument): Don't merge classes above
number of words.
--- gcc/config/i386/i386.c.jj 2014-07-09 10:41:18.000000000 +0200
+++ gcc/config/i386/i386.c 2014-07-11 10:23:04.276634260 +0200
@@ -6581,7 +6581,7 @@ classify_argument (enum machine_mode mod
bit_offset);
if (!num)
return 0;
- for (i = 0; i < num; i++)
+ for (i = 0; i < num && i < words; i++)
classes[i] = merge_classes (subclasses[i], classes[i]);
}
}
Jakub