gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] Incompatible CARDINAL8


From: Gaius Mulley
Subject: Re: [Gm2] Incompatible CARDINAL8
Date: Mon, 14 Jun 2010 11:41:56 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Martin Kalbfuß <address@hidden> writes:

> Hi,
>
>  I have a record
>
>  Version = RECORD
>      major : SYSTEM.CARDINAL8;
>      minor : SYSTEM.CARDINAL8;
>      path  : SYSTEM.CARDINAL8;
>  END;
>
> If I do a STextIO.WriteCard(v.major, 1);
>
> I get garbage like 134681089S as output. I assumed, that a CARDINAL8 is
> casted to a CARDINAL.
>
> if I do
>
> VAR major : CARDINAL;
>
> major := v.major;
>
> STextIO.WriteCard(major, 1);
>
> The result is correct.
>
> Compiler version is 0.78  (20100606)

Hi Martin,

I'm having a little difficulty reproducing the problem above.  Here is
my test code:

MODULE int8field ;

IMPORT SYSTEM ;
FROM libc IMPORT exit ;
FROM STextIO IMPORT WriteString, WriteLn ;
FROM SWholeIO IMPORT WriteCard ;

PROCEDURE assert (a, b: CARDINAL) ;
BEGIN
   WriteCard(a, 1) ; WriteLn ;
   IF a#b
   THEN
      exit(1)
   END
END assert ;

TYPE
   Version = RECORD
                major : SYSTEM.CARDINAL8;
                minor : SYSTEM.CARDINAL8;
                path  : SYSTEM.CARDINAL8;
             END ;

VAR
   v: Version ;
BEGIN
   v.major := 1 ;
   v.minor := 2 ;
   v.path  := 3 ;
   WriteCard(v.major, 1) ; WriteLn ;
   WriteCard(v.minor, 1) ; WriteLn ;
   WriteCard(v.path, 1) ; WriteLn ;
   assert(v.major, 1) ;
   assert(v.minor, 2) ;
   assert(v.path, 3)
END int8field.


which appears to pass with:

$ gm2 --version
GNU Modula-2  0.91  (20100611)
  grafted onto GCC 4.1.2

I guess your code must differ somehow..

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]