Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28945 Discussions

side-effects in internal pure procedures not reported by the compiler

riad_h_1
Novice
251 Views

Dear,

a probable bug in ifx: in the following example, a pure internal procedure modifies a variable of its parent subroutine.

ifx fails to report this side effect (see also the discussion at https://fortran-lang.discourse.group/t/internal-pure-procedure-with-side-effect/8974).

Thank you.

module foo_m
   implicit none
contains

   subroutine foo ( a, b )
      integer, intent(in out) :: a, b
      b = 0
      call sbar ( a )
      b = fbar ( a )
   contains
   
      pure subroutine sbar ( a )
         integer, intent(out) :: a
         a = b
         b = 1 ! <- the compiler should report this error 
      end subroutine sbar
      
      pure function fbar ( a ) result( r )
         integer, intent(in) :: a
         integer             :: r
         r = a+b
         b = 2 ! <- same here
      end function fbar
   
   end subroutine foo
end module foo_m

 

0 Kudos
1 Reply
TobiasK
Moderator
147 Views

@riad_h_1

thanks for reporting that, I agree that should not happen. I escalated this to our dev team


Reply