This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR43737
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 13 Apr 2010 14:21:51 +0200 (CEST)
- Subject: [PATCH] Fix PR43737
The assert in c_readstr is obviously wrong and from it we derive
the loop trip count and thus peel the loop completely and then
warn about the out-of-bounds array access.
Fixed like the following, bootstrapped and tested on
x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-04-13 Richard Guenther <rguenther@suse.de>
PR bootstrap/43737
* builtins.c (c_readstr): Fix assert.
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 158258)
+++ gcc/builtins.c (working copy)
@@ -560,7 +560,7 @@ c_readstr (const char *str, enum machine
&& GET_MODE_SIZE (mode) > UNITS_PER_WORD)
j = j + UNITS_PER_WORD - 2 * (j % UNITS_PER_WORD) - 1;
j *= BITS_PER_UNIT;
- gcc_assert (j <= 2 * HOST_BITS_PER_WIDE_INT);
+ gcc_assert (j < 2 * HOST_BITS_PER_WIDE_INT);
if (ch)
ch = (unsigned char) str[i];