This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case
- From: Paul Koning <paul_koning at dell dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 23 Nov 2010 10:12:17 -0500
- Subject: [RFA] Fix c_readstr for BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case
c_readstr produces the wrong answer if BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN and the size of the constant requested matches the word size. The attached patch corrects this.
Checked on pdp11. I'm running a bootstrap and make check on Linux for completeness.
Ok to commit?
paul
ChangeLog:
2010-11-23 Paul Koning <ni1d@arrl.net>
* builtins.c (c_readstr): Fix byte order if BYTES_BIG_ENDIAN !=
WORDS_BIG_ENDIAN.
Index: builtins.c
===================================================================
--- builtins.c (revision 166480)
+++ builtins.c (working copy)
@@ -609,7 +609,7 @@
if (WORDS_BIG_ENDIAN)
j = GET_MODE_SIZE (mode) - i - 1;
if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN
- && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
+ && 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);