- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using Fortran Compiler 18.0.3.210 . The following program compiles and runs without any errors. However, there is a bug because a variable declared as INTENT(in) is passed to a subroutine where it is INTENT(inout). Can the latest version of the compiler catch this bug?
module mymod
contains
pure subroutine myplus( a, b, c )
implicit none
integer,intent(inout):: a !!!
integer,intent(in):: b
integer,intent(out):: c
a = a * 2
c = a + b
return
end subroutine myplus
!--------------------------------------
pure function myadd( a, b ) result(c)
implicit none
integer,intent(in):: a, b
integer c
call myplus( a, b, c ) ! ERROR: a is intent(in), goes to intent(inout)
return
end function myadd
end module mymod
!=================================================
program test_intent
use mymod, only: myadd
implicit none
integer a, b
a = 1
b = 2
write(*,*) myadd(a, b)
stop
end program test_intent
Link Copied
0 Replies
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