https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61632
--- Comment #22 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Created attachment 33160 [details]
> Updated patch taking care of valgrind error
>
> This patch includes fixing the valgrind error by allocating and setting
> the NULL byte at the end of the format string.
With this patch all my tests for this PR pass without problem: no more memory
corruption and the caret is at the right position!-).
I have two questions:
(1) my understanding of
offset = (j > 60) ? j - 40 : 0;
j -= offset;
width = dtp->format_len - offset;
is to set j to 40 and to decrease width by j-40 if j>60.
This part is now removed, should not we limit offset to something?
(2) Do you need me to package one or two of my tests for the caret position?
Indeed I'ld perfectly happy if the behavior reported in comment 10 would be at
least understood. Note that with the code
program p
call ss0()
call ss()
end program p
subroutine ss0
CHARACTER(3), save :: ZTYP(4)
DATA ZTYP /'WWW','XXX','YYY','ZZZ'/
write(10,500,err=10,iostat=iosa) 'AAA','BBB',0.0,ZTYP
500 FORMAT(2(A3),1PE13.5,A3)
return
10 write(10, *)
write(10, *) 'iostat =', iosa
end subroutine ss0
subroutine ss
CHARACTER(3), save :: ZTYP(4)
DATA ZTYP /'WWW','XXX','YYY','ZZZ'/
write(10,600) 'AAA','BBB',0.0,ZTYP
600 FORMAT(A3,1PE13.5,2(A3))
end subroutine ss
gives at run time
[Book15] f90/bug% cat fort.10
AAABBB 0.00000E+00WWW
iostat = 5006
but my mother is saying "le mieux est l'ennemi du bien" (~ the best is against
the good) so I think this should not defer the commit of the patch.