From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16a35419d117fb15 X-Google-Attributes: gid103376,public From: rracine@draper.com (Roger Racine) Subject: Re: discriminant Date: 1999/07/12 Message-ID: #1/1 X-Deja-AN: 500085413 Sender: nntp@news.draper.com (NNTP Master) References: <3789bfc2.97977684@news.dsuper.net> Organization: Draper Laboratory Newsgroups: comp.lang.ada Date: 1999-07-12T00:00:00+00:00 List-Id: In article <3789bfc2.97977684@news.dsuper.net> fluffy_doo@dsuper.net writes: >I'm having problems with the use of a discriminant for a RECORD >that is meant to hold the value for a High Precision Real Number >(my own type defined in an ADT). I did *not* get any compilation >time errors for any of the things I have done (described below). >In my .ADS I have the following private structure: >PRIVATE > TYPE T_Sign_Temp IS (POSITIVE, NEGATIVE, ABSENT); > SUBTYPE T_Sign IS T_Sign_Temp RANGE POSITIVE..NEGATIVE; > SUBTYPE T_Digit IS integer RANGE 0..9; > TYPE T_Mantissa IS ARRAY (1..MAX_MANT_200) OF T_Digit; > SUBTYPE T_Len_Mantissa IS positive RANGE 1..MAX_SIG_FIG_30; > SUBTYPE T_Power IS integer RANGE integer'first..integer'last; > SUBTYPE T_Positive_Power IS T_Power RANGE 0..integer'last; > TYPE T_Kind IS ( INT, REAL, NONE ); > TYPE T_Number ( kind : T_Kind := NONE ) IS > RECORD > Sign : T_Sign := POSITIVE; > Mant : T_Mantisse := (OTHERS => 0); > Len : T_Lng_Mantisse := 0; > CASE kind IS > WHEN REAL => Point : natural RANGE 0..MAX_SIG_FIG_30 := 1; > Power_R : T_Power := 0; > WHEN INT => Power_I : T_Positive_Power := 0; > WHEN NONE => NULL; > END CASE; > END RECORD; >When I assign a value to the Power_R for a real numbrer, the "Point" >field also changes (mysteriously), and after it has changed I can no >longer assign a new value to it. On top of this, the new value that >"Point" takes is *outside* my subtype range and no exception is >raised ! It tends to take a value a bit over 500, while its top limit >is a constant with a value of 30 !?!? I got the value and the >moment of the change occuring from the debugger. I had to make a couple of changes to your source to get it to compile without warnings or errors. Specifically, note that the spelling of "mantissa" is not consistent. I assume those were typos in your message. When I corrected those, I got a warning about Len raising Constraint_Error (it is assigned a value of 0, which is outside its range), so I changed it to have an initial value of 1. After that, I created a test, which worked fine on the latest GNAT (3.12a) on Windows NT. What version of what compiler are you using on what host? Can you provide a complete test that fails? Roger Racine