https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119856

--- Comment #14 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Created attachment 61556
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61556&action=edit
Patch to correct runtime behavior of repeated use of the same format

This patch corrects a latent problem. many years ago to improve performance,
once a format string was parsed and checked for errors, the tokenized format
was saved in a cache. Later, this cache is checked and if the string is found,
the saved tokenized format is reused without reparsing and rechecking. So in
this testcase, no error was given for the problem at line 10.

program badfmt
  implicit none

  character(10):: fmt = "(AI5)"  ! Not parameter, so not examined at compile
time
  integer :: ioerr
  ioerr = 0
  write (*, fmt, iostat=ioerr) 'value =', 42
  print *, 'ioerr =', ioerr

  write (*, fmt) 'value =', 43   ! <--- no error found

end program badfmt

This patch checks to see if an error was seen before saving the parsed format. 
If so, it is not saved. This ensures that each use of thay particular format
string is reparsed and rechecked.

Reply via email to