Also, add the statement rev := ~rev
IF y.mode # Reg THEN LoadR(y); rev := ~rev END;(* <<< add this line *)
MODULE BugMeter;
TYPE
Meter = POINTER TO RECORD
maxVal : INTEGER;
steps : INTEGER
END;
PROCEDURE Do*;
VAR
pos, val : INTEGER;
meter : Meter;
BEGIN
NEW(meter);
meter.maxVal := 9999;
meter.steps := 100;
val := 500;
pos := SHORT (LONG (val) * meter.steps DIV meter.maxVal);
HALT(100) (*This traps with pos = 5*)
END Do;
END BugMeter.Do
On Mon, Dec 19, 2011 at 12:22 PM, Robert <robert.campbell_{([at]})nowhere.xy
Luowy
I tried this, and my source code compiles, but crashes at run-time.
The line is (now !)
pos := SHORT (LONG (val) * meter.steps DIV meter.maxVal);
All variables are INTEGERS.
val is 0, meter.steps is 100, and meter.maxVal is 9999.
If I copy meter.maxVal into a local temporary variable (maxVal) it works fine with the unmodified compiler, but still crashes at runtime with the modification.
I need to use LONGINTs in the expression because sometimes val & maxVal may exceed 2^31 / 100.
I believe there is a clever way of computing a * b MOD c without suffering overflow problems; it is used in ObxRandom. But understanding that trick is a theoretical detour I haven't the time for just now.
I know my posted example is incomplete as a runnable program; it was meant to be a minimal example of the compiler problem.
Regards
Robert
On 19/12/2011 17:12, luowy{([at]})nowhere.xy
add one line:
DevCPC486.FloatDOp
...
| div:
IF y.mode # Reg THEN LoadR(y); END;(*<<< add this line *)
IF rev THEN Dev2CPL486.GenFDOp(FDIVR, y) ELSE Dev2CPL486.GenFDOp(FDIV, y) END;
Floor(y,FALSE)
...
----- 原文 -----
发件人: Aubrey.McIntosh{([at]})nowhere.xy
主 题: Re: [BLACKBOX] Possible compiler bug ?
时 间: 2011年12月19日 22:25:12
It compiles to completion in V4:iOP2 RC/NM V1.7 22.1.1996
compiling DemoMeter; new symbol file 58And the user program traps at the expected place on the NIL pointer.
I think that the BlackBox compiler is a descendant of the original OP2 compiler. There is an early 90s paper that describes the internal data structures of OP2. Is it obvious to anyone how to walk down the source for the two compiler execution paths side by side to see what catches the eye?
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1890 / Virus Database: 2108/4689 - Release Date: 12/18/11
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy--
Aubrey McIntosh, Ph.D.
1502 Devon Circle
Austin TX 78723-1814
http://home.grandecom.net/~amcintosh/aubrey/Search/
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
Received on Mon Dec 19 2011 - 22:25:13 UTC