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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6da15369b6c53c77 X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: LLQ: -1 a valid boolean? Date: 2000/05/23 Message-ID: <8ge39b$g45$1@nnrp1.deja.com>#1/1 X-Deja-AN: 626170037 References: <39253CD0.C8DC893D@telepath.com> <8g8o3b$9l0$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x72.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Tue May 23 14:06:47 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) Date: 2000-05-23T00:00:00+00:00 List-Id: In article <8g8o3b$9l0$1@nnrp1.deja.com>, Robert Dewar wrote: > In article <39253CD0.C8DC893D@telepath.com>, > Ted Dennison wrote: > > You'd think that a value that is legal in situ ought to be > > legal to assign as well. Then again, if Ada_Boolean'Size = 8 > > or 32 or something, then I can see where one might argue that > > a value of -1 (all bits set) is out of range of the possible > > Boolean values, and thus should raise > > Constraint_Error. > > > > So what's right? > > Not only is the compiler's behavior conforming, it is actually > what one would expect, given that you most certainly expect > that boolean objects have a size of 8 (the choice of a size > of 1 for boolean objects is typically impractical on most > architectures due to the task indepedence requirement). > > Your code is just wrong here, and you are going to have to > deal with these booleans in a completely different manner. That's what I was afraid of. > If your compiler implements Interfaces.Fortran, then everything > should be fine, since the type Logical should work properly. Except that sometimes the value comes from a Fortran program, and sometimes it comes from a C program. I just ended up doing the following, which looks damn silly (so I had to comment it copiously), but works: if To_Bool_Ptr(Addr).all then return True; else return False; end if; -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.