soccer jersey forums.silverfrost.com :: View topic - Allocate on assignment for CHARACTER variables
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 

Allocate on assignment for CHARACTER variables

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



Joined: 21 Oct 2020
Posts: 67

PostPosted: Wed Sep 20, 2023 2:39 pm    Post subject: Allocate on assignment for CHARACTER variables Reply with quote

While trying to use the "allocate on assignment" feature for CHARACTER variables implemented with FTN95 version 8.95, both following examples fail to compile with version 8.97.2. The error output seems to me contradictory.
Code:
PROGRAM Simon
IMPLICIT NONE
CHARACTER (LEN=:), ALLOCATABLE :: Says

CALL Sim('clap hands', Says)
WRITE(*,*) Says

CONTAINS

SUBROUTINE Sim(What, Out)
  IMPLICIT NONE
  CHARACTER (LEN=*), INTENT(IN):: What
  CHARACTER (LEN=:), INTENT(OUT), ALLOCATABLE :: Out
  Out = 'Simon says '//What
END SUBROUTINE Sim

END PROGRAM Simon

Quote:
error 1234 - CHARACTER variable OUT must be ALLOCATABLE
error 941 - OUT is a scalar dummy argument and so cannot be ALLOCATABLE

Code:
PROGRAM Simon
IMPLICIT NONE
CHARACTER (LEN=:), ALLOCATABLE :: Says

Says=Sim('clap hands')
WRITE(*,*) Says

CONTAINS

FUNCTION Sim(What) RESULT(Out)
  IMPLICIT NONE
  CHARACTER (LEN=*), INTENT(IN):: What
  CHARACTER (LEN=:), ALLOCATABLE :: Out
  Out = 'Simon says '//What
END FUNCTION Sim

END PROGRAM Simon

Quote:
error 456 - ALLOCATABLE is an illegal attribute specifier for a RESULT variable such as (RESULT of SIMON~SIM)
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Sep 20, 2023 2:56 pm    Post subject: Reply with quote

It looks like the use of CHARACTER variables in this way has not be considered.

I have added these to the list of missing features.
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: Tue Aug 13, 2024 9:48 am    Post subject: Reply with quote

This feature has now been added for the next release of FTN95 but only for x64.
Back to top
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Tue Aug 13, 2024 3:43 pm    Post subject: Reply with quote

Paul
Thank you very much for having added this feature.
Back to top
View user's profile Send private message
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Tue Aug 20, 2024 8:53 am    Post subject: Reply with quote

Paul
I have tried both code samples with the new FTN95 version 9.04.0.0. The version with FUNCTION (2nd sample) works, thank you, the version with SUBROUTINE (1st sample) raises the following exception at runtime:
Quote:
Unknown exception (c0000374) at address 7ff99e2ac399

Within file ntdll.dll
In RtlIsZeroMemory at address 119
In RtlIsZeroMemory at address E3
In _misaligned_access at address 492
In _misaligned_access at address 77A
In _misaligned_access at address AC65
In RtlGetCurrentServiceSessionId at address C95
In RtlFreeHeap at address 51
In _DEALLOCATE$ at address 69
Within file CLEARWIN64.DLL
In ILT+1625(??$parse_integer_from_string_J_W$$T__crt_strtoxYA_JQEB_W$$THQEAU__crt_locale_pointersZ) at address 2
Within file Simon1.exe
in SIMON~SIM at address 77


RAX = 394e54465c73746e RBX = 00000000c0000374 RCX = 5c73747365545c35 RDX = 652e316e6f6d6953
RBP = 0000000000405090 RSI = 0000000000000001 RDI = 00007ff99e317780 RSP = 000000000240fb00
R8 = 0000000000000000 R9 = 00007ff99d160000 R10 = 00007ff99d17aaa0 R11 = 0000000000620062
R12 = 0000000000000000 R13 = 0000000000000000 R14 = 0000000000000000 R15 = 0000000000000000

7ff99e2ac399) jmp 7ff99e2ac39b
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Aug 20, 2024 3:41 pm    Post subject: Reply with quote

jlb

Thanks. I will have another go at this.
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: Tue Sep 10, 2024 8:18 am    Post subject: Reply with quote

This has now been added for the next release of FTN95
Back to top
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Tue Sep 10, 2024 5:37 pm    Post subject: Reply with quote

Paul
Thanks for having implemented this feature.
Back to top
View user's profile Send private message
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Fri Sep 13, 2024 1:10 pm    Post subject: Reply with quote

I continued to play with this new feature. Compiling the following example
Code:
PROGRAM Simon
IMPLICIT NONE
CHARACTER (LEN=:), ALLOCATABLE :: Says

Says=Sim('clap hands')//' and '//Sim('sit down')
WRITE(*,*) Says

CONTAINS

FUNCTION Sim(What) RESULT(Out)
  IMPLICIT NONE
  CHARACTER (LEN=*), INTENT(IN):: What
  CHARACTER (LEN=:), ALLOCATABLE :: Out
  Out = 'Simon says '//What
END FUNCTION Sim

END PROGRAM Simon

fails with the error message
Quote:
error 163 - Internal compiler error


The next example
Code:
PROGRAM Simon
IMPLICIT NONE
CHARACTER (LEN=:), ALLOCATABLE :: Says

Says=Sim('clap hands')
WRITE(*,*) Says

CONTAINS

FUNCTION Sim(What) RESULT(Out)
  IMPLICIT NONE
  CHARACTER (LEN=*), INTENT(IN):: What
  CHARACTER (LEN=:), ALLOCATABLE :: Out
  Out = 'Simon says nothing'
END FUNCTION Sim

END PROGRAM Simon

fails with the error message
Quote:
error 773 - Variable of follows another operand (possible unexpected space?)
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Sep 13, 2024 1:44 pm    Post subject: Reply with quote

jlb

Thank you for the feedback.

I think that your second sample will be relatively easy to fix.
A fix for your first sample could prove to be very time consuming so the issue may end up on the back burner for some time.

There is quite a lot in "allocate on assignment" that is proving to be a heavy drain on resources and one has to ask if the time would be better spent on other developments.

In the meantime FTN95 will require a more traditional approach in this context.
Back to top
View user's profile Send private message AIM Address
jlb



Joined: 21 Oct 2020
Posts: 67

PostPosted: Fri Sep 13, 2024 2:22 pm    Post subject: Reply with quote

Paul
The whole thing started when I was curious about the "allocate on assignment" feature for CHARACTER variables implemented in FTN95 version 8.95, more or less just for fun. Some of these attempts were not successful and are the origin of this thread. It was not my intention to commit development resources to such features and I fully understand that other priorities have to be set. Thanks as always for your patience and educational responses.
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