Re: What does -gnato do?



"Peter C. Chapin" <pchapin@xxxxxxxxx> writes:

Martin Krischik <krischik@xxxxxxxxxxxxxxxxxxxxx> wrote in
news:1636357.gWrtX1Nq9K@xxxxxxxxxxxxxxxxxxx:

You are right in that if I do the overflow with values that can only be
known at run time, the -gnato makes a difference. Without the option,
the results wrap around but with the option I get Constraint_Error.

So it seems that without -gnato the externally visible behavior of a
program depends on the extent with which the compiler can analyze the
code. If the compiler's analysis is sufficiently deep I might end up
with a Constraint_Error that I wouldn't get if the analysis was not as
deep. I'm not sure how I feel about that. It seems like a bad idea to me
although I can't articulate exactly why I feel that way.

You are right to feel dismayed by such behavior; it means the program
is not portable among compilers, or even compiler versions.

Which is why standard Ada does not allow such behavior. GNAT without
-gnato is _not_ a standard Ada compiler!

In defense of GNAT, specifying -gnato does add size to the code, and
it runs somewhat slower. Back when GNAT was first introduced, there
were lots of rumors about how slow and bloated Ada is. So AdaCore made
the decision to opt for speed and small size by default, rather than
complete Ada correctness. A lot of us complained about that, but it's
too late to complain about it now.

--
-- Stephe
.



Relevant Pages

  • Re: Next Ada compiler for Debian: the votes so far
    ... The Debian changelog is specific to each package, ... AdaCore has not "gone proprietary", GNAT is, remains and will always ... > a compiler remained free). ... just not been provided to those who want to do proprietary software. ...
    (comp.lang.ada)
  • Re: GNAT verses A# for soft-realtime system
    ... I have a choice of GNAT or A# for my programming environment. ... Whether you go with a supported compiler, or with a free version of GNAT ... version of Ada you want to use. ... Do the additional features of 2005 target real-time systems? ...
    (comp.lang.ada)
  • Re: can one build commercial applications with latest gnat and other licenses related questions...
    ... "can I sell binaries without source code, if compiled with GNAT ... compiler runtime, which is licensed under the Gnu GPL, which requires ... I'll assume by 'gcc ada' you mean the official Free Software ... The gcc ada runtime has the GMGPL license, ...
    (comp.lang.ada)
  • Re: GNAT verses A# for soft-realtime system
    ... I have a choice of GNAT or A# for my programming environment. ... Whether you go with a supported compiler, or with a free version of GNAT ... version of Ada you want to use. ... Windows target but could also use .net on top of that. ...
    (comp.lang.ada)
  • Re: GNAT verses A# for soft-realtime system
    ... I have a choice of GNAT or A# for my programming environment. ... Whether you go with a supported compiler, or with a free version of GNAT ... version of Ada you want to use. ... Windows target but could also use .net on top of that. ...
    (comp.lang.ada)