 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 299
|
Posted: Tue Mar 05, 2013 6:31 am Post subject: |
|
|
I think I cleared up almost all my USE statements a while ago, but I'm still getting a few odd outcomes. However, it seems that ONLY does not seem to function as I would expect. For example, the following program uses module m1, but only subroutine s1. However, the program calls s2, which has not been used, and the program still compiles, runs, and gives the correct result. Although s2 is not declared as private, I would still have thought that the ONLY would have made it invisible to the program.
Code: | MODULE m1
INTEGER :: i1
CONTAINS
SUBROUTINE s1 ()
i1=1
PRINT *, i1
END SUBROUTINE s1
SUBROUTINE s2 ()
i1=2
PRINT *, i1
END SUBROUTINE s2
END MODULE m1
!
PROGRAM p
USE m1, ONLY: s1
CALL s2 ()
END PROGRAM p |
Last edited by simon on Wed Apr 10, 2013 10:06 pm; edited 1 time in total |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Tue Mar 05, 2013 9:57 am Post subject: |
|
|
I have logged this for investigation. |
|
Back to top |
|
 |
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Thu Apr 04, 2013 8:32 am Post subject: |
|
|
I have run into this issue too. As far as I can see the ONLY list is being ignored by the compiler and everything in the module that isn't private becomes accessible.
Code: |
module mmm
contains
subroutine xxx
print *, 'xxx called'
end subroutine xxx
subroutine yyy
print *, 'yyy called'
end subroutine yyy
end module mmm
program main
use mmm, only : xxx
call xxx
call yyy ! Shouldn't work, but does!
end
|
In this code, the explist shows the second call uses the module name decoration.
CALL MMM!YYY
It should say
CALL YYY
so that the error can be detected by the Linker or at Run-time. _________________ Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8211 Location: Salford, UK
|
Posted: Tue Apr 16, 2013 2:01 pm Post subject: |
|
|
This bug has now been fixed for the next release. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|