https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30617
--- Comment #46 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to michael from comment #43)
> I recently came across this bug and found this report. It would seem to me
> that if code is non-conformant to a standard that the compiler should report
> this e.g. with a Warning (if not an Error) rather than quietly building the
> executable which then hangs (or has some other non-determinant behaviour)
Checks at compile-time and at run-time are two different beasts.
Compile-time is always preferred, but cannot be wholly general, especially
if the unit number is not a constant.
It might be possible to generate warning when a function that
is called from the argument list of an external I/O statement
does external I/O. This would also generate false positives, for
example for code like
write (10,*) my_func(10.)
...
integer function my_func(a)
real, intent(in) :: a
write (20,*) 'In my_func: argument is: ', a
...
It could also cause false positives for cases like
integer function my_func(a)
logical, parameter :: debug = .false.
real, intent(in) :: a
if (debug) write (10,*) 'In my_func: argument is: ',a
This kind of warning could be made to work with modules (add an
attribute like "this_does_external_io"), but if the implementation
is hidden in a submodule, this would not be propagated through the
module files.
So, I'm not 100% convinced this would be a good idea.