- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
implicit none
integer, parameter :: n = 2
external :: fred
call test(n, fred)
end
implicit none
integer :: n
real*8, external :: func
return
real*8 function func1(xp)
implicit none
real*8 :: xp(n)
integer :: k
func1 = func()
write(6,'(
return
end function
end subroutine
fred = 100.0
return
end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You didn't say, but I'm guessing you are building this with debug enabled, yes?
I wasn't able to reproduce it except with -Zi.
Obviously, it's a bug; please submit a support request. Unfortunately, it still fails with current sources.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lorri,
Yes, debug enabled. I will submit to Premier Support.
Adrian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler should have generated an error message for your programming error. Instead the compiler has an error in that it "remembered" the external attribute of the dummy variable func in subroutine test when it nested into function func1. This resulted in code generated to call a local subroutine of the name func (appropriately name mangled).
The programming error (assuming you think your program is correct) is that func is a stack variable (dummy arg) to test. func1 can be called (it isn't in your sample code) without regard to subroutine nesting level, e.g. had your code contained func2, func3, func4.
Were test to call func1 it is concievable that the compiler could figure out where the dummy variable func is located (I do not think it does), but then consider what happens should func2 call func1. And func3 calling func2. Let alone a recursive call to any internal func let alone to test.
Now, this could be solved in the compiler if for subroutine test it creates a static name mangled variable (P.P322.TEST$FUNC.UP$), then copies the dummy argument func into this variable on entry and then substitutes all references to func to use the name mangled variable.
This would work as long as test was not recursively called with different function for func (this could be fixed with pushing/poping old value of P.P322.TEST$FUNC.UP$ on call/return of test).
This is either a compiler error or programming error, not a linker problem.
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page