comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com
Subject: Re: Need exception despite Machine_Overflows is false
Date: 1998/12/19
Date: 1998-12-19T00:00:00+00:00	[thread overview]
Message-ID: <75fg9u$d29$1@nnrp1.dejanews.com> (raw)
In-Reply-To: m3hfutol0d.fsf@mheaney.ni.net

In article <m3hfutol0d.fsf@mheaney.ni.net>,
  Matthew Heaney <matthew_heaney@acm.org> wrote:
> `-gnato'
>      Enable other checks, not normally enabled by
> default, including
>      numeric overflow checking, and access before
> elaboration checks.
>
> Ah, silly me, I assumed that "numeric overflow checking"
> meant check for
> numeric overflow!


Well perhaps silly you for reading only the summary of the
switch and not the full documentation :-) The documentation
of the -gnato switch in the GNAT users guide says:

  -gnato

  Enables overflow checking for integer operations.
  This causes GNAT to generate slower and larger executable
  programs by adding code to check for both overflow and
  division by zero (resulting in raising Constraint_Error
  as required by Ada semantics).

  Note that the -gnato switch does not affect the code
  generated for any floating-point operations; it applies
  only to integer operations. For floating-point, GNAT has
  the Machine_Overflows attribute set to False and the
  normal mode of operation is to generate IEEE NaN and
  infinite values on overflow or invalid operations
  (such as dividing 0.0 by 0.0).

Clear enough I think! Note that the summary was correct, in
that if you have Machine_Overflows set to False, then an
out of range floating-point result is *not* an overflow in
the sense of the predefined overflow check in the language.
But in any case, when looking up the definition of
switches, always consult the full documentation, and not
just the quick summary!

This is a good opportunity to reiterate and once
again urge people to read the GNAT documentation if you are
using this compiler (and indeed the advice applies to any
other compiler I would assume!) There are lots of
interesting facilities available, and I am always surprised
(and a bit disappointed) to run into both students and
hobbyists using the public version of GNAT, and customers
using GNAT Professional with support who have not read the
manual and are unaware of many features that they might
find useful if they knew about them!

Robert Dewar
Ada Core Technologies

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1998-12-19  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-17  0:00 Need exception despite Machine_Overflows is false Pascal MALAISE
1998-12-17  0:00 ` Matthew Heaney
1998-12-18  0:00   ` dewarr
1998-12-18  0:00     ` Matthew Heaney
1998-12-19  0:00       ` dewar [this message]
1998-12-18  0:00 ` Stephen Leake
1998-12-18  0:00   ` Pascal MALAISE
1998-12-19  0:00     ` dewarr
1998-12-18  0:00   ` Matthew Heaney
replies disabled

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