Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7bc0b9

Browse files
committed
SF patch 730594: assert from longobject.c, line 1215.
Some version of gcc in the "RTEMS port running on the Coldfire (m5200) processor" generates bad code for a loop in long_from_binary_base(), comparing the wrong half of an int to a short. The patch changes the decl of the short temp to be an int temp instead. This "simplifies" the code enough that gcc no longer blows it.
1 parent ce6829a commit c7bc0b9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Objects/longobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,8 +1201,8 @@ long_from_binary_base(char **str, int base)
12011201
bits_in_accum = 0;
12021202
pdigit = z->ob_digit;
12031203
while (--p >= start) {
1204-
unsigned char ch = (unsigned char)*p;
1205-
digit k;
1204+
int k;
1205+
char ch = *p;
12061206

12071207
if (ch <= '9')
12081208
k = ch - '0';
@@ -1212,8 +1212,8 @@ long_from_binary_base(char **str, int base)
12121212
assert(ch >= 'A');
12131213
k = ch - 'A' + 10;
12141214
}
1215-
assert(k < base);
1216-
accum |= k << bits_in_accum;
1215+
assert(k >= 0 && k < base);
1216+
accum |= (twodigits)(k << bits_in_accum);
12171217
bits_in_accum += bits_per_char;
12181218
if (bits_in_accum >= SHIFT) {
12191219
*pdigit++ = (digit)(accum & MASK);

0 commit comments

Comments
 (0)