Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26756 Discussions

Nested blocks prohibit function assignment

Benjamin_D_2
Beginner
113 Views
When nesting block statements into each other, it is no longer possible to access the result value of an outer function.Consider
program nestBlock

   implicit none  
   
   contains
      integer function test() result(Res)
         block
            block
               Res = 1
            end block
         end block
      end function
end program
This leads to error #7816: Invalid assignment to function result of external procedure. The error occurs regardless of whether a result variable is defined or the function name is used by itself. Assignment works for one single block, but as soon as the second level starts, the result can no longer be written to. Compiler: Visual Fortran Compiler 17.0.2.187
0 Kudos
1 Reply
Kevin_D_Intel
Employee
113 Views

Thank you for reporting this defect and for the convenient reproducer. I escalated it to Development.

(Internal tracking id: DPD200420015)

Reply