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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ecc38b3271b36b88 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: What is the warning about builtin-function on gcc-4.6.0 ? Date: Sat, 26 Mar 2011 17:48:05 +0000 Organization: A noiseless patient Spider Message-ID: References: <87aagiclte.fsf@mid.deneb.enyo.de> <475d10ca-5d4e-490c-9b88-e12cd3cd3faa@b13g2000prf.googlegroups.com> <87d3lejjyv.fsf@mid.deneb.enyo.de> <6c748f70-7e75-49b4-a467-d1d2d6b24323@w9g2000prg.googlegroups.com> <87k4flhoeg.fsf@mid.deneb.enyo.de> <8762r5hl2u.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx03.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="20463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nOOOk7zpaFuQKGlhoYeUs/mp5j0ERtsU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin) Cancel-Lock: sha1:Visgb09YeEinhoGpnqS0CBG9OQE= sha1:sTDa1H97dA7mlXtdZ9tmIBzbspg= Xref: g2news2.google.com comp.lang.ada:19445 Date: 2011-03-26T17:48:05+00:00 List-Id: Florian Weimer writes: > * Simon Wright: > >> Florian Weimer writes: >> >>> * Simon Wright: >>> >>>> ytomino 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.