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

Run-time diagnostics for shape mismatches in array assignments possible?

FortranFan
Honored Contributor III
314 Views

This is based on discussions in this thread at comp.lang.fortran: https://groups.google.com/forum/#!topic/comp.lang.fortran/OCWxsF-Tm0U.

The following simple code compiles with no errors or warnings with Intel Fortran and raises no run-time exceptions during the i=j array assignment at line 17 even though the array extents are different (as noted on the comp,lang.fortran forum, NAgFor does give a run-time error).  Run-time diagnostics is set to /check:all.  Is it possible to give some run-time diagnostics here?

module m 

   implicit none 

contains 

   subroutine s ( i ) 

      !.. Argument list 
      integer, intent(inout) :: i(:) 

      !.. Local variables 
      integer :: j(2) 

      !.. 
      j = 42 
      i = j 

   end subroutine s 

end module m 

program p 

   use m, only : s 
    
   implicit none 

   integer :: ia(1) 

   ia = 0 
   call s(ia) 
   write (*,*) " ia = ", ia 

   stop 

end program p 

Upon execution,

  ia =  42
Press any key to continue . . .

 

0 Kudos
1 Reply
Steven_L_Intel1
Employee
314 Views

We have a long-outstanding request for such a feature, which I would very much like to see myself. It hasn't been implemented yet.

0 Kudos
Reply