soccer jersey forums.silverfrost.com :: View topic - Compiler does not flag error in assignment statement
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 

Compiler does not flag error in assignment statement

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



Joined: 31 Oct 2006
Posts: 1896

PostPosted: Wed Jan 04, 2023 2:08 pm    Post subject: Compiler does not flag error in assignment statement Reply with quote

In the following program, the first executable statement is in error because the right hand side expression is array valued, and the variable on the left is scalar.

Compiler versions 8.90 and 8.92 do not detect the error at compile time or, with /check, at run time.

Code:
program xm
   implicit none
   integer :: ix(5) = [5, 4, 8, 2, 7], ir
!
   ir = minloc(ix)      ! Error: return value is array, IR is scalar
   print *,ir
   print *,minloc(ix)
end program
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Jan 05, 2023 8:05 am    Post subject: Reply with quote

mecej4

At the moment an error report is only generated when /ISO is applied.

The logic behind this choice is not obvious to me. There should at least be a warning if not an error report. I will log it as needing investigation.

This issue is discussed here...
http://forums.silverfrost.com/viewtopic.php?t=2034&start=0&postdays=0&postorder=asc&highlight=minloc.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Thu Jan 05, 2023 9:01 am    Post subject: Reply with quote

For the next release of FTN95 this code will generate an error report when /ISO is used and will otherwise generate a warning message.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2864
Location: South Pole, Antarctica

PostPosted: Thu Jan 05, 2023 4:38 pm    Post subject: Reply with quote

How this demo example should be written to be correct?
Intuitively it looks OK.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Jan 05, 2023 5:30 pm    Post subject: Reply with quote

Code:
program xm
   implicit none
   integer :: ix(5) = [5, 4, 8, 2, 7], ir(1)
   ir = minloc(ix)
   print *,ir
   print *,minloc(ix)
end program
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2864
Location: South Pole, Antarctica

PostPosted: Fri Jan 06, 2023 5:10 am    Post subject: Reply with quote

Then in this specific case it is reasonable that FTN95 not following the crowd and not strictly supporting Standard. It is very natural for the compiler to adopt such a jargon, slang or idiomatic expression and excuse the human for not declaring ir as an array and declare it as usual scalar variable. It's counterintuitive to declare variable as an array with just 1 element for minloc to work. To me the warning indeed could be enough here.

I remember similar case caused me brain damage 20 years ago when i tried to use minloc and maxloc Smile
Back to top
View user's profile Send private message
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