From: Simon Wright <simon@pushface.org>
Subject: Re: What is the warning about builtin-function on gcc-4.6.0 ?
Date: Sat, 26 Mar 2011 17:48:05 +0000
Date: 2011-03-26T17:48:05+00:00 [thread overview]
Message-ID: <m24o6pg4dm.fsf@pushface.org> (raw)
In-Reply-To: 8762r5hl2u.fsf@mid.deneb.enyo.de
Florian Weimer <fw@deneb.enyo.de> writes:
> * Simon Wright:
>
>> Florian Weimer <fw@deneb.enyo.de> writes:
>>
>>> * Simon Wright:
>>>
>>>> ytomino <aghia05@gmail.com> writes:
>>>>
>>>>> nn...then, there are no function to take infinity and NaN...
>>>>
>>>> 'Valid should do the trick.
>>>>
>>>> FP_Value := 1.0 / 0.0;
>>>> if FP_Value'Valid then
>>>> -- it won't be
>>>
>>> This is a compiler bug.
>>
>> I don't understand what you mean.
>
> The standard requires that FP_Value'Valid is true.
>
>> If the compiler doesn't raise an exception on division by zero (it's
>> allowed not to, and GNAT doesn't) it will (in this case) set the result
>> to +Inf, and 'Valid will return False.
>
> My understanding is that an implementation must either raise
> Constraint_Error, or the evaluation of an expression must result in a
> valid value.
ARM 13.9.2 doesn't include division by zero as a means of producing an
invalid float.
However, A.5.3(12) ('Machine_Overflows) implies that Constraint_Error
doesn't _have_ to be raised. It doesn't say what happens - that's
implementation-defined, M.2(123) and G.2.1(13).
The GNAT RM
(http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gnat_rm/Strict-Conformance-to-the-Ada-Reference-Manual.html#Strict-Conformance-to-the-Ada-Reference-Manual)
says
"Note that the result of a floating point arithmetic operation in
overflow and invalid situations, when the Machine_Overflows attribute
of the result type is False, is to generate IEEE NaN and infinite
values. This is the case for machines compliant with the IEEE
floating-point standard, but on machines that are not fully compliant
with this standard, such as Alpha, the -mieee compiler flag must be
used for achieving IEEE confirming behavior (although at the cost of
a significant performance penalty), so infinite and and NaN values
are properly generated."
I don't see anything in the above that says that 'Valid should produce
False for Inf/NaN, but GNAT - on Intel & PowerPC hardware - certainly
does.
next prev parent reply other threads:[~2011-03-26 17:48 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 [this message]
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
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