Jump to content
Excelsior Forums
Sign in to follow this  
AlexIljin

Compiler bug: type guard causes double procedure call

Recommended Posts

XDS 2.51, default configuration, Windows platform.

Problem: if a type guard is applied directly to a procedure result, the procedure will be called twice.

Test.ob2 module:

MODULE Test; <* MAIN+ *><* O2EXTENSIONS+ *>

IMPORT Out;

TYPE

  Ansector = POINTER TO AnsectorDesc;

  AnsectorDesc = RECORD

  END;

  Descendant = POINTER TO DescendantDesc;

  DescendantDesc = RECORD (AnsectorDesc)

  END;

VAR desc: Descendant;

PROCEDURE GetThis (): Ansector;

VAR res: Descendant;

BEGIN

  Out.String ('GetThis ');

  NEW (res);

  RETURN res

END GetThis;

BEGIN

  desc := GetThis ()(Descendant);

  (* Although the GetThis procedure is called only once, the 'GetThis' string

    * will be output twice because of the type guard bug. *)

END Test.

<<EOF>>

Test.prj project file:

!module Test.ob2

<<EOF>>

Command to compile: xc =p Test.prj

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×