forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

generic interface

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
simon



Joined: 05 Jul 2006
Posts: 268

PostPosted: Wed May 27, 2020 3:24 pm    Post subject: generic interface Reply with quote

I reported the following code to NAG as a suspected error, since their compiler was complaining about the two subroutines s1 and s2 being indistinguishable.
Code:
Module m
 Interface s
   Module Procedure s1
   Module Procedure s2
 End Interface s
!
Contains
!
 Subroutine s1 (i, c)
   Integer, Intent(In) :: i
   Character(Len=*), Intent(In) :: c
   Return
 End Subroutine s1
!
 Subroutine s2 (c, i)
   Character(Len=*), Intent(In) :: c
   Integer, Intent(In) :: i
   Return
 End Subroutine s2
End Module m

The code compiles without an error in FTN95. However, NAG indicated that the code is incorrect because
Code:
Call s (i=i, c=c)

would be ambiguous since the ordering of the arguments does not matter even though the arguments are not optional. So perhaps FTN95 should issue a compilation error message?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Thu May 28, 2020 8:10 am    Post subject: Reply with quote

Thank you for the feedback. You are right. FTN95 does not fault this even when using /ISO.
Back to top
View user's profile Send private message AIM Address
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Mon Jun 08, 2020 12:04 pm    Post subject: Reply with quote

what would be the effect of this in this case ? ..... wrong answers ? .... or the appearance in some form of Dan Devilry ?
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Mon Jun 08, 2020 3:58 pm    Post subject: Reply with quote

Here is a fleshed out version of the test code. Since the ambiguity is not detected and the violation of the standard is not detected, the fact that the program runs is, in itself, the error. If the program output is seen to be reasonable, the bug can go undetected for years.

Code:
Module m
 Interface s
   Module Procedure s1
   Module Procedure s2
 End Interface s
!
Contains
!
 Subroutine s1 (i, c)
   Integer, Intent(In) :: i
   Character(Len=*), Intent(In) :: c
   print *,'S1: ',c,i
   Return
 End Subroutine s1
!
 Subroutine s2 (c, i)
   Character(Len=*), Intent(In) :: c
   Integer, Intent(In) :: i
   print *,'S2: ',c,i
   Return
 End Subroutine s2
End Module m

Program Smn
use m
character(len=5) :: cc = 'ABCDE'
integer :: i = 123
! when args are passed without keywords, the order/type suffices to select the specific routine
call s(i,cc)
call s(cc,i)
! when keywords are used, both s1 and s2 would match; if s1 is tried first, it will match
! and the bug is not found unless s2 is also tested even after s1 succeeded.
call s(c=cc, i=i)
call s(i=i, c=cc)
end Program
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Jul 04, 2020 8:47 am    Post subject: Reply with quote

This issue has now been fixed for the next release of FTN95. This kind of ambiguous interface will now be reported as an error.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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