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: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Bug in 'gnatmake' (Was: Range check for type 'Integer') Date: Mon, 17 Jun 2013 15:23:11 +0200 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: <87r4g0g9c0.fsf@adaheads.sparre-andersen.dk> References: <7f33982d-3bcf-452e-a3b3-3a0a28505ff1@x20g2000vbe.googlegroups.com> NNTP-Posting-Host: 77.241.138.169.bredband.3.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: loke.gir.dk 1371475391 30749 77.241.138.169 (17 Jun 2013 13:23:11 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Mon, 17 Jun 2013 13:23:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:KkrHtpnzFJBRn5Ws0GvJELRLJsc= X-Original-Bytes: 2708 Xref: number.nntp.dca.giganews.com comp.lang.ada:181887 Date: 2013-06-17T15:23:11+02:00 List-Id: Peter Brooks wrote: > This is 134217728 > This is 268435456 > This is 536870912 > This is 1073741824 > This is -2147483648 > This is 0 > This is 0 > This is 0 > This is 0 > This is 0 > This is 0 > This is 0 > This is 0 > ..... [forever] > > So the 'Integer' has rolled over to negative and then rolled back to 0 > - but with no run-time error. > > Why is there no range check error on type Integer? Because there is a major error in the design of GNAT. You have to give 'gnatmake' a very specific set of command line flags to turn it into an Ada compiler: -fstack-check -- Generate stack checking code -gnata -- Enable assertions -gnatE -- Dynamic elaboration checking -gnato -- Overflow checking If you use the GNAT Project Manager (and '*.gpr' files), I suggest that you copy this file project file and use it in all you (GNAT based) Ada projects: http://repositories.jacob-sparre.dk/ada-user-journal-tools/src/40323d1c952e20020bd056f2df698d252c4cd87f/ada_2012.gpr?at=default Here is a simple example of how to use the file: http://repositories.jacob-sparre.dk/ada-user-journal-tools/src/40323d1c952e20020bd056f2df698d252c4cd87f/auj_tools.gpr?at=default The more complicated version has something like: package Compiler is for Default_Switches ("Ada") use Ada_2012.Compiler'Default_Switches ("Ada") & ("-some-extra-switches"); end Compiler; instead of: package Compiler renames Ada_2012.Compiler; Greetings, Jacob -- "Never interrupt your enemy when he is making a mistake."