Re: [BLACKBOX] CONSTant expressions

From: Campbell, Robert (SELEX GALILEO, UK) <"Campbell,>
Date: Thu, 31 Jan 2008 09:06:53 -0000

----boundary-LibPST-iamunique-1150819952_-_-
Content-type: text/plain

Hello

I implied earlier that CONST multiplies had some problems.
Below is a clearer example:

MODULE DemoConstMult;IMPORT StdLog;

(*
PROCEDURE NotUsed;
  CONST
    zero = 0.;
  VAR
    z : REAL;
  BEGIN
    z := zero
  END NotUsed;
*)

PROCEDURE Do*;
  CONST
    aa = -5.;
    zz = aa * 0.;
  VAR
    zero, inf : REAL;
  BEGIN
    zero := zz;
    inf := 1. / zero;

    StdLog.String ('inf = '); StdLog.Real (inf); StdLog.Ln
  END Do;

END DemoConstMult.

<Q> DevDebug.Unload
<Q> DemoConstMult.Do

 
This module outputs "inf = -inf", as it should.
But if I uncomment NotUsed it outputs "inf = inf".

I have a theory (well a guess actually!).

The compiler puts the CONSTants it needs into a table.
It avoids duplicates by not repeating the same constant more than once.
It uses '=' as a test for 'sameness'.
This is wrong. (+0.) = (-0.), but they are not the same.


I think I regard this behaviour as a compiler bug.


Regards,

Robert

SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1150819952_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaG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KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqXHBhcg0KVGhpcyBlbWFpbCBhbmQgYW55IGF0dGFjaG1lbnRzIGFyZSBjb25maWRlbnRp
YWwgdG8gdGhlIGludGVuZGVkXHBhcg0KcmVjaXBpZW50IGFuZCBtYXkgYWxzbyBiZSBwcml2aWxl
Z2VkLiBJZiB5b3UgYXJlIG5vdCB0aGUgaW50ZW5kZWRccGFyDQpyZWNpcGllbnQgcGxlYXNlIGRl
bGV0ZSBpdCBmcm9tIHlvdXIgc3lzdGVtIGFuZCBub3RpZnkgdGhlIHNlbmRlci5ccGFyDQpZb3Ug
c2hvdWxkIG5vdCBjb3B5IGl0IG9yIHVzZSBpdCBmb3IgYW55IHB1cnBvc2Ugbm9yIGRpc2Nsb3Nl
IG9yXHBhcg0KZGlzdHJpYnV0ZSBpdHMgY29udGVudHMgdG8gYW55IG90aGVyIHBlcnNvbi5ccGFy
DQoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKlxwYXINClxwYXINClxwYXINCi0tLS1ccGFyDQpUbyB1bnN1YnNjcmliZSwg
c2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBM
SVNUUy5PQkVST04uQ0h9fQAAAABA
----boundary-LibPST-iamunique-1150819952_-_---
Received on Thu Jan 31 2008 - 10:06:53 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:31:05 UTC