🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4690

Re: Is this a compiler bug?

#4690
From: Bengt J Nilsson
Date: Fri, 03 Mar 1989 20:18
40 lines
1997 bytes
In article <1712@psu-cs.UUCP> bartonr@psu-cs.UUCP (Robert Barton) writes:
>
>  I have a variable, called code, representing a word of machine code
>which consists of one or more bit fields of various sizes.  Since I will
>be doing a number of bit manipulation operations on this variable it has
>been declared with type BITSET.  However for testing purposes it will be
>useful to assign code various values within a given range using a loop.
>Now the problem: using the statement
>
>  INC(CARDINAL(code), 1);
>
>the compiler gives an error message of "variable expected".  Does this
>sound like a compiler bug or an error on my part?  The references I have
>read indicate that INC should take any ordinal type, including CARDINAL.
>BITSET and CARDINAL are both 16 bits in this implementation.  Using
>
>  code := BITSET(CARDINAL(code) + 1);
>
>is acceptable to the compiler, so I can work around it, but I'm just
>wondering if anyone else has come across this.

I'm afraid it's an error on your part. The error message is absolutely         
correct, it expects a variable, not an expression.
You see, INC requires a named variable to work on, and the CARDINAL
operation copies the value of its parameter and gives it (the copied value)
the new type.
So the equivalent (correct) to your code would be.

   x := CARDINAL( code );
   INC( x, 1 );
   code := BITSET( x );

But apparently you shorted it down a bit.

Hope this explains it.

---Bengt

bnilsson@watdragon.waterloo.edu         on visit from Lund University, Sweden
bengt@dna.lu.se
Technical Details
Message-ID: <11998@watdragon.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watdragon!bnilsson
References: <1712@psu-cs.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watdragon!bnilsson
From: bnilsson@watdragon.waterloo.edu (Bengt J Nilsson)
Newsgroups: comp.lang.modula2
Subject: Re: Is this a compiler bug?
Message-ID: <11998@watdragon.waterloo.edu>
Date: 3 Mar 89 20:18:07 GMT
References: <1712@psu-cs.UUCP>
Reply-To: bnilsson@watdragon.waterloo.edu (Bengt J Nilsson)
Organization: Data Structures Group, C.S. Dept., U. of Waterloo
Lines: 40