This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/51638] gfortran optimization breaks a single variable used as both input and output for subroutine call


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51638

--- Comment #13 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-09 10:01:59 UTC ---
(In reply to comment #12)
> I am surprised to see that none of the compilers I tested (gfortran, ifort,
> g95) complain about the fact that the same variable is used as both
> intent(in) and intent(out) variable. Shouldn't it be at least a warning?


gfortran with -Waliasing (or -Wall) actually warns - but not by default:

  call iei4ei(in4,in4)
              1
Warning: Same actual argument associated with INTENT(IN) argument 'inpu' and
INTENT(OUT) argument 'oupu' at (1)


The argument agains warning by default is that one can write perfectly valid
code such as:

call iei4ei(in4, in4, false)
contains
subroutine iei4ei (out, in, mod)
  integer :: out, in
  logical :: mod
  if (mod)
    out = 5
end subroutine ie4ei


Nevertheless, one could think of warning by default.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]