- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- « Previous
-
- 1
- 2
- Next »
22 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That alien is from Bluto
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I could swear that alien is the spitting image of my brother - but maybe only after a few beers
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »