Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III

Regression with compiler 18.0 (update 1?): assignment using a contained function to a host associated variable

Fyi on support request #03224678 submitted at the Intel Online Service Center.

Consider the program shown below.  It gives an incorrect result for an assignment using a function to a variable where the function result is aliased via host association to the same variable. 

This issues appears to be a regression.  Intel Fortran 17.0 compiler update 1 gave the expected result as shown below.

Intel Fortran team has been requested to fix this regression issue and also to add this code to their regression suite for Intel Fortran compiler revision acceptance testing.

! Test for assignment using a function to an object where the function result
! is aliased via host association to the same object

   implicit none

   integer, parameter :: MAGIC_NUM = 42
   integer, parameter :: N = 1

   integer :: x(N), i

   x = MAGIC_NUM

   x = f()

   print *, "x = ", x, "; Expected values: ", [( MAGIC_NUM, i=1,N )]
   if ( any(x /= [( MAGIC_NUM, i=1,N )]) ) then
      print *, "Incorrect result for a function result aliased to a host association"
      print *, "variable to which the function is assigned."
   else
      print *, "Successful test."
   end if

   stop

contains

   function f() result( r )

      integer :: r(N)

      r = 0
      r = x

      return

   end function

end
C:\temp>ifort /standard-semantics /warn:all /check:all /traceback p.f90 -o p.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R
) 64, Version 18.0.1.156 Build 20171018
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.12.25831.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:p.exe
-subsystem:console
-incremental:no
p.obj

C:\temp>p.exe
x = 0 ; Expected values: 42
Incorrect result for a function result aliased to a host association
variable to which the function is assigned.
C:\temp>ifort /standard-semantics /warn:all /check:all /traceback p.f90 -o p.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R
) 64, Version 17.0.1.143 Build 20161005
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.

-out:p.exe
-subsystem:console
-incremental:no
p.obj

C:\temp>p.exe
x = 42 ; Expected values: 42
Successful test.

 

0 Kudos
1 Reply
Highlighted
Moderator

Thank you for reporting this.

Thank you for reporting this. Our Fortran engineers are on it.

Devorah - Intel® Developer Support
0 Kudos