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/85599] invalid optimization: function not always evaluated in logical expression


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

--- Comment #5 from janus at gcc dot gnu.org ---
Here is a variant of the original test case, now with a PURE procedure:


program lazy

   logical :: flag

   flag = .false.
   flag = check() .and. flag
   flag = flag .and. check()

contains

   pure logical function check()
      check = .true.
   end function

end


In this case I would think it's perfectly valid to optimize away both calls to
'check', in particular because there is actually no way to check for the user
whether the function 'check' is being called (other than looking at the
assembly code etc).

However, I could not find any distinctions between pure and impure functions in
the standard, when it comes to the question of function evaluation and
optimizations. Any pointers appreciated.

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