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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c462e8ad74872a98,start X-Google-Attributes: gid103376,public From: "Jerry van Dijk" Subject: Question on modular types Date: 1997/01/04 Message-ID: <01bbfa96$66d516a0$8d2d5c8b@jerryware>#1/1 X-Deja-AN: 207757021 organization: *JerryWare HQ*, Haarlem, Holland newsgroups: comp.lang.ada Date: 1997-01-04T00:00:00+00:00 List-Id: Much to my supprise, the following compiles and runs: with Ada.Text_IO; use Ada.Text_IO; with Interfaces.C; use Interfaces.C; procedure Test is type My_Int is mod 2 ** 32; uint : unsigned; A_Int : My_Int; begin uint := -1; -- Well, its a C type... :-) if uint'Valid then Put_Line ("uint Valid"); else Put_Line ("uint Invalid"); end if; A_Int := -1; -- (A) if A_Int'Valid then Put_Line ("A_Int Valid"); else Put_Line ("A_Int Invalid"); end if; A_Int := My_Int (uint); -- (B) if A_Int'Valid then Put_Line ("A_Int Valid"); else Put_Line ("A_Int Invalid"); end if; if A_Int = -1 then -- Compare works ??? Put_Line ("A_Int is -1 !?!"); else Put_Line ("A_Int is" & A_Int'Img); end if; end Test; Clearly, all values are invalid, and that without inporting any values from the outside world. I expected the line marked (A) to give an compilation error because of 3.5.4(10) or else the line marked (B) to generate a constraint error because of 3.5.4(19). I suspect that (B) doesn't fail since type_conversion is not one of the operations mentioned in 4.5, and that (A) doesn't result in an error because of the second sentence in 3.5.4(10) since its base type is Integer according to 3.5.4(1). Still, its not what I expected, so perhaps does someone has an explantion ? (BTW using GNAT 3.05 on DOS and 3.07 on Linux, with -gnato) Thanks, Jerry.