Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Using the 'value' attribute

$
0
0
module mymod
    implicit none
    type my_t
	integer :: a = 3
    end type my_t

contains
    subroutine by_value(i,m) bind(c,name='BY_VAL')
	use iso_c_binding
	integer(c_int), intent(in), value :: i
	type(my_t), intent(out) :: m
	m%a = i
    end subroutine by_value

end module mymod

program test
	use mymod
	implicit none
	integer :: i
	type(my_t) :: m

	i = 5

	call by_val(i,m)
	print *, m%a

	call by_value(i,m)
	print *, m%a

end program test

 

> ifort tc.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204
Copyright (C) 1985-2016 Intel Corporation.  All rights reserved.

 

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

-out:tc.exe
-subsystem:console
tc.obj

> tc
  1060107240
           5

The above code shows the inconsistency. If I remove the output argument 'm' in the calls then both output values are '5' as I'd expect. I get the same result with Version 14.0.1.139 Build 20131008.

 


Viewing all articles
Browse latest Browse all 5691