Hi Jakob,
thanks for the detailed explanation!
> The other much easier but uglier option is to use a temporary buffer:
> char buffer[21];
> sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, hwint_val);
> gfc_error ("... %s ...", ... buffer ...);
> This works, as it uses the host sprintf i.e. *printf family for which
> HOST_WIDE_INT_PRINT_DEC macro is designed.
The attached followup patch implements this.
Can anybody affected by current HEAD confirm that this fixes bootstrap?
Thanks,
Harald
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 492867e12cb..eaabbffca4d 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4552,11 +4552,12 @@ substring_has_constant_len (gfc_expr *e)
if (istart <= iend)
{
+ char buffer[21];
if (istart < 1)
{
- gfc_error ("Substring start index (" HOST_WIDE_INT_PRINT_DEC
- ") at %L below 1",
- istart, &ref->u.ss.start->where);
+ sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, istart);
+ gfc_error ("Substring start index (%s) at %L below 1",
+ buffer, &ref->u.ss.start->where);
return false;
}
@@ -4567,9 +4568,9 @@ substring_has_constant_len (gfc_expr *e)
length = gfc_mpz_get_hwi (ref->u.ss.length->length->value.integer);
if (iend > length)
{
- gfc_error ("Substring end index (" HOST_WIDE_INT_PRINT_DEC
- ") at %L exceeds string length",
- iend, &ref->u.ss.end->where);
+ sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, iend);
+ gfc_error ("Substring end index (%s) at %L exceeds string length",
+ buffer, &ref->u.ss.end->where);
return false;
}
length = iend - istart + 1;