soccer jersey forums.silverfrost.com :: View topic - Compiler does not report incorrect invocation of SHAPE()
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 report incorrect invocation of SHAPE()

 
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: 1897

PostPosted: Tue Feb 06, 2024 4:39 pm    Post subject: Compiler does not report incorrect invocation of SHAPE() Reply with quote

The SHAPE intrinsic function may not be applied to assumed-size subprogram arguments. The Fortran 2003 Standard says (emphasis added):

13.7.108 SHAPE (SOURCE [, KIND])
9 Description. Returns the shape of an array or a scalar.
10 Class. Inquiry function.
11 Arguments.
SOURCE may be of any type. It may be a scalar or an array. It shall not be an
unallocated allocatable or a pointer that is not associated. It shall not be an
12 assumed-size array.

Here is a test program where this requirement is not met, and the compiler does not report an error or warning:
Code:
program shapebug
   implicit none
   integer i,ki(10)
   ki = [(i+4, i=1,10)]
   print *,'Shape(ki) = ',shape(ki)
   call sub(ki)

   CONTAINS

   subroutine sub(ij)
      implicit none
      integer ij(*)
      print *,'In SUB, shape(arg) = ',shape(ij)
      return
   end subroutine sub
end program


The output from FTN95 (32-bit):
Code:
 Shape(ki) =           10
 In SUB, shape(arg) =     56687753


The output from FTN95 (64-bit):
Code:
 Shape(ki) =           10
 In SUB, shape(arg) =            1


A compile time warning or error message would be helpful.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Feb 07, 2024 8:15 am    Post subject: Reply with quote

mecej4

Many thanks for the welcome feedback. I have added this to the log.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Wed Feb 07, 2024 9:16 am    Post subject: Reply with quote

An error report has been added for the next release of FTN95.
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