On Sun, Jan 8, 2017 at 4:29 PM, Dominique d'Humières <[email protected]> wrote:
>> r244027 reverts r244011. Sorry for the breakage. It seems to affect
>> all i686 as well in addition to power, maybe all 32-bit hosts.
>
> For the record, I see the following failures with an instrumented r244026 (as
> in pr78672)
>
> FAIL: gfortran.dg/char_length_20.f90 -O* execution test
> FAIL: gfortran.dg/char_length_21.f90 -O* execution test
> FAIL: gfortran.dg/repeat_2.f90 -O1 execution test
> …
> FAIL: gfortran.dg/repeat_2.f90 -Os execution test
> FAIL: gfortran.dg/widechar_6.f90 -O1 execution test
> …
> FAIL: gfortran.dg/widechar_6.f90 -Os execution test
> FAIL: gfortran.dg/widechar_intrinsics_6.f90 -O* execution test
>
> The run time failures are all of the kind
Sorry, I missed that I had to use an instrumented build to catch
these, and assumed everything was Ok once I managed to regtest cleanly
on i686.
The following patch fixes these issues for me, does it work for you?
diff --git a/libgfortran/intrinsics/string_intrinsics_inc.c
b/libgfortran/intrinsics/string_intrinsics_inc.c
index 0da5130..74a994b 100644
--- a/libgfortran/intrinsics/string_intrinsics_inc.c
+++ b/libgfortran/intrinsics/string_intrinsics_inc.c
@@ -177,23 +177,25 @@ string_trim (gfc_charlen_type *len, CHARTYPE
**dest, gfc_charlen_type slen,
gfc_charlen_type
string_len_trim (gfc_charlen_type len, const CHARTYPE *s)
{
- const gfc_charlen_type long_len = (gfc_charlen_type) sizeof (unsigned long);
- gfc_charlen_type i;
+ if (len <= 0)
+ return 0;
+
+ const size_t long_len = sizeof (unsigned long);
- i = len - 1;
+ size_t i = len - 1;
/* If we've got the standard (KIND=1) character type, we scan the string in
long word chunks to speed it up (until a long word is hit that does not
consist of ' 's). */
if (sizeof (CHARTYPE) == 1 && i >= long_len)
{
- int starting;
+ size_t starting;
unsigned long blank_longword;
/* Handle the first characters until we're aligned on a long word
boundary. Actually, s + i + 1 must be properly aligned, because
s + i will be the last byte of a long word read. */
- starting = ((unsigned long)
+ starting = (
#ifdef __INTPTR_TYPE__
(__INTPTR_TYPE__)
#endif
--
Janne Blomqvist