[Info-vax] VMS Basic strings class D vs class S

Arne Vajhøj arne at vajhoej.dk
Wed Feb 28 10:26:12 EST 2024


On 2/28/2024 9:56 AM, Scott Dorsey wrote:
> In article <urnggb$3trjg$1 at dont-email.me>,
> =?UTF-8?Q?Arne_Vajh=C3=B8j?=  <arne at vajhoej.dk> wrote:
>> On 2/26/2024 4:17 PM, Stephen Hoffman wrote:
>>> If the app code assumes a dynamic arriving and gets handed static, the
>>> RTL will either copy it, or space-pad the results into the static, or
>>> the RTL will return a string truncation error. BASIC space-pads into
>>> static string buffers if and as needed. Or truncates with an error.
>>
>>> Apps expecting to work with dynamic descriptors might fail with the
>>> truncation error as mentioned, and apps expecting to massage static
>>> descriptors directly and not coded sufficiently cautiously around any
>>> arriving dynamic strings can fail with heap and other errors.
>>
>> Basic cannot stuff 200 bytes into a 100 bytes fixed length string. That
>> is fair.
> 
> Fortran can! And you likely won't notice that you have damaged some other
> memory until you get a SIGSEGV in some totally unrelated part of your code.

:-)

Note that VMS Fortran need to be actively mislead to do this.

$ type bufovr.for
       program bufovr
       character*4 s1, s2
       common /b/s1,s2
       write(*,*) %loc(s1), %loc(s2)
       s2 = 'XXXX'
       call subbo1(s1)
       write(*,*) s1//s2
       call subbo2(s1)
       write(*,*) s1//s2
       end
c
       subroutine subbo1(s)
       character*(*) s
       s = 'ABCDEFGH'
       end
c
       subroutine subbo2(s)
       character*8 s
       s = '12345678'
       end
$ for bufovr
$ link bufovr
$ run bufovr
                196608                196612
ABCDXXXX
12345678

Arne





More information about the Info-vax mailing list