This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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];


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]