comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: What is the warning about builtin-function on gcc-4.6.0 ?
Date: Wed, 30 Mar 2011 07:41:58 -0700 (PDT)
Date: 2011-03-30T07:41:58-07:00	[thread overview]
Message-ID: <f628184d-314b-4349-b2a8-1579209fd3c2@f15g2000pro.googlegroups.com> (raw)
In-Reply-To: wcc62r022b4.fsf@shell01.TheWorld.com

On Mar 30, 5:57 am, Robert A Duff <bobd...@shell01.TheWorld.com>
wrote:

> >...If the
> > compiler's behavior is incorrect and doesn't raise C_E for
> > abs(Integer'First) when it's supposed to, then presumably
> > abs(Integer'First) will still be Integer'First (on a normal 2's
> > complement machine), and EQUAL will return TRUE.
>
> Right, that would be a compiler bug.
>
> I was imagining a compiler that returns the right answer for
> abs(Integer'First).  It's not entirely unreasonable.  Perhaps
> Integer is 32 bits, and the arithmetic is done in a 64-bit
> register, which can obviously represent 2**31 just fine.

Offhand, I don't think that makes sense, though.  The "abs" predefined
function is predefined to return Integer'Base; if the mathematical
answer doesn't fit in Integer'Base, I don't see how the right answer
can be returned.  Actually, 3.5.4(11) says that the predefined subtype
Integer is constrained to the base range of its type, and 3.5.4(9)
says that the base ranges of integer types are symmetric about zero
except possibly for an extra negative number.  So I don't think the
scenario you envision can legally exist.  If arithmetic is done in a
64-bit register, the program may temporarily have the correct
mathematical answer for abs(Integer'First); but if that answer doesn't
fit in 32 bits, nothing can be done with that value---the compiler
would have to raise C_E right away.  (*) So I don't know what you mean
by "returns the right answer", but I don't think it's possible in any
meaningful sense.  Maybe I've lost track of what you were trying to
say.

(*) If the value were used as part of a larger expression involving
predefined operators, there might be a Chapter 11 Implementation
Permission that would allow computation to continue using the 64-bit
value.  Here, though, it's just passed as a parameter of type Integer
to a user-defined function, so the constraint check would have to take
place.  Bottom line: there's really no way for Equal(abs(X),X) to
return False if X=Integer'First.

                             -- Adam




  reply	other threads:[~2011-03-30 14:41 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-26  6:32 What is the warning about builtin-function on gcc-4.6.0 ? ytomino
2011-03-26  8:45 ` Florian Weimer
2011-03-26  9:13   ` ytomino
2011-03-26  9:43     ` Florian Weimer
2011-03-26 10:07       ` ytomino
2011-03-26 10:24         ` Florian Weimer
2011-03-26 15:14           ` Dmitry A. Kazakov
2011-03-26 21:36             ` ytomino
2011-03-27  9:50               ` Dmitry A. Kazakov
2011-03-26 14:50         ` Simon Wright
2011-03-26 15:50           ` Florian Weimer
2011-03-26 16:32             ` Simon Wright
2011-03-26 17:02               ` Florian Weimer
2011-03-26 17:48                 ` Simon Wright
2011-03-26 18:48                   ` Florian Weimer
2011-03-27  2:08                 ` Randy Brukardt
2011-03-27  8:37                   ` Florian Weimer
2011-03-27 16:41                     ` Robert A Duff
2011-03-27 17:21                       ` Florian Weimer
2011-03-27 17:56                         ` Robert A Duff
2011-03-27 16:51                     ` Robert A Duff
2011-03-27 17:05                       ` Florian Weimer
2011-03-27 17:14                         ` Robert A Duff
2011-03-29  2:20                           ` Randy Brukardt
2011-03-29 18:35                             ` Robert A Duff
2011-03-29 23:35                               ` Randy Brukardt
2011-03-30  1:02                               ` Adam Beneschan
2011-03-30 12:57                                 ` Robert A Duff
2011-03-30 14:41                                   ` Adam Beneschan [this message]
2011-03-30 18:39                                     ` Robert A Duff
2011-03-30 19:28                                   ` Randy Brukardt
2011-03-26 21:58       ` ytomino
2011-03-26 22:00         ` Florian Weimer
2011-03-26 22:22 ` anon
2011-03-26 22:36   ` ytomino
2011-03-27 12:00     ` anon
2011-03-27 18:50       ` ytomino
2011-03-27 23:35         ` anon
2011-03-27 23:42         ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox