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,2fa53692def716b5 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: null range from 1 element discrete type Date: 1999/11/22 Message-ID: #1/1 X-Deja-AN: 551685366 Sender: bobduff@world.std.com (Robert A Duff) References: <3835D5A0.F906D31D@mitre.org> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1999-11-22T00:00:00+00:00 List-Id: "Robert I. Eachus" writes: > Technically there is no "perfect" solution, as the compiler is > allowed to choose a size of zero bits for such a type. The compiler is *required* to choose 'Size = 0, and of course that's the natural thing for the compiler to do -- anything else would require a special case in the compiler. But I don't see what 'Size has to do with the issue. >...But if the > (sub)type is a generic formal type, you shouldn't have to worry about > this possibility. > > Since you always want a null range try: T'Val(1) .. T'Val(0) Since > 'Val returns the base type of T, as long as the base type of T contains > at least one bit you are safe. T'Val(1) will raise Constraint_Error if T is an enum type with only one value. The number of bits allocated for objects of type T has nothing to do with this. - Bob