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

Argument kind conformance is not enforced?

PierU
Novice
324 Views

I never noticed that until today, but apparently the following code compiles with any ifort/ifx version, just with a warning, and gives garbage:

program foo
implicit none

   integer(8) :: i = huge(0) + 1_8

   print*, "i = ", i
   call init(i)

contains

   subroutine init(a)
   integer, intent(in) :: a
   print*, "a = ", a
   end subroutine init

end


Ouput with ifx 2024:

/app/example.f90(7): warning #6075: The data type of the actual argument does not match the definition. [I]
call init(i)
----------^

Program returned: 0
Program stdout

i = 2147483648
a = -2147483648

 

This implicit casting is a violation of the standard, but looks intentional. It is restricted to the integer case (no casting between real and integer, or between real kinds). Nonetheless I don't think it's a good idea at all...

 

BTW, how to disable this behavior?

0 Kudos
0 Replies
Reply