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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: -fdump-ada-spec Date: Wed, 08 Oct 2014 20:48:12 +0100 Organization: A noiseless patient Spider Message-ID: References: <20141007101042.08f99687@atmarama.ddns.net> <1028866756434371637.714832laguest-archeia.com@nntp.aioe.org> <20141008092318.18ca2ecd@atmarama.ddns.net> <8761fu8jc5.fsf_-_@ludovic-brenta.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="865ecc8333c04b7dc8d5f87fc772110b"; logging-data="31014"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nQBMSekfq+Z0c13rdB0QEeclsfXwSgDU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:t5Pb2Acp3hnYjgSFMXTocAOgOSY= sha1:dx5u6qGd8ZJvgDgTHkBmuahkejM= Xref: news.eternal-september.org comp.lang.ada:22256 Date: 2014-10-08T20:48:12+01:00 List-Id: Ludovic Brenta writes: >> Apparently one should use g++ rather than gcc, because it makes a better >> job of it. >> >> GNAT GPL 2014 does translate (some) macros; it doesn't always get it >> right, eg >> >> #define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ >> #define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ >> #define MAXFLOAT 0x1.fffffep+127f >> >> // have to have _something_ besides the constants or no .ads gets >> // generated. >> extern float sinf(float); >> >> turns into >> >> pragma Ada_2005; >> pragma Style_Checks (Off); >> >> with Interfaces.C; use Interfaces.C; >> >> package math_h is >> >> >> M_SQRT2 : constant := 1.41421356237309504880168872420969808; -- ./math.h:1 >> M_SQRT1_2 : constant := 8#.707106781186547524400844362104849039#; -- ./math.h:2 > ^^ ^ > > Isn't that a blatant bug? Either in the Ada or in the C source? Yes; like I said, it doesn't always get it right. And it doesn't understand hex floats either: 16#1.fffffep+127f# is *not* a good translation of 0x1.fffffep+127f ! I have reported these problems to AdaCore, but as they have always said the translation isn't expected to be perfect, so it'll be very low on their priority list.