Pascal Compiler x86 [truncate] attribute

Post Reply

Topic author
rodprince
Contributor
Posts: 18
Joined: Mon Aug 14, 2023 6:00 pm
Reputation: 0
Status: Offline

Pascal Compiler x86 [truncate] attribute

Post by rodprince » Mon Aug 14, 2023 6:08 pm

Issue with the x86 Pascal Compiler.

VSI Pasacl x64-64 X6.3-138 (50x6f) on OpenVMS x86-64 V9.2-1

If you use a [truncate] attribute in a procedure,. you throw an access violation if the parameter is not specified from the calling code.

Code: Select all

program test(input, output)
type
varying_string = varying [132] of char;

procedure do_error (action : [truncate] varying_string);
begin
  if present( action ) then
    begin
    writeln( action );
    end
  else
    begin
    writeln( "no action" );
    end;
end;

begin
  do_error;
end.


Topic author
rodprince
Contributor
Posts: 18
Joined: Mon Aug 14, 2023 6:00 pm
Reputation: 0
Status: Offline

Re: Pascal Compiler x86 [truncate] attribute

Post by rodprince » Tue Aug 15, 2023 5:57 pm

I forgot to mention, if you compile & link with /debug it appears to work fine. The access vio is in non-debug code.


jreagan
VSI Expert
Master
Posts: 139
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Pascal Compiler x86 [truncate] attribute

Post by jreagan » Wed Aug 16, 2023 2:03 pm

I think I fixed this for the next kit. I'll try it and let you know.

I hope to get the out this week or next week.


jreagan
VSI Expert
Master
Posts: 139
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Pascal Compiler x86 [truncate] attribute

Post by jreagan » Thu Aug 17, 2023 9:50 am

I tried it with my latest compiler and it still fails with /OPTIMIZE. I think the issue is that the optimizer either inline expanded that call to do_error (or turned it into a tail call by jumping to do_error) and the 0 arg-count got turned into a non-zero arg-count. /NOOPTIMZE avoids it.

Post Reply