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=-2.5 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, STOX_REPLY_TYPE,TVD_FINGER_02 autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e01fe1b326df26d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!proxad.net!usenet-fr.net!news.enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Division by zero Date: Sat, 11 Jun 2005 21:00:32 -0500 Organization: Cuivre, Argent, Or Message-ID: References: NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1118541539 97736 212.85.156.195 (12 Jun 2005 01:58:59 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Sun, 12 Jun 2005 01:58:59 +0000 (UTC) Cc: comp.lang.ada@ada-france.org To: "Lurker" Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:11289 Date: 2005-06-11T21:00:32-05:00 The reason for the difference is that because both terms of line 1 are known at compile time, the computation is performed at compile time, and thus raises the exception. Since the numerator of line 2 is a variable, the compiler does not attempt any computation, and thus does not signal an error. Constraint_Error will be raised at runtime. ----- Original Message ----- From: "Lurker" Newsgroups: comp.lang.ada To: Sent: June 11, 2005 4:03 PM Subject: Division by zero > Hi, > > I'm curios about the problem which I discovered by accident. > The code below is of course very much reduced to show > the it: > > function x(a: integer) return integer is > > some_constant: constant := 0; > > begin > > -- return 1/some_constant; -- line 1 > > -- return a/some_constant; -- line 2 > > end; > > > > If line 1 is uncommented compiler (Gnat 3.15 for Widows) > > produces the expected error about division by zero. > > If line 2 is uncommented it passes compilation with no problem. > > Surely that's not right? Or did I miss something? > > > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada-france.org > http://www.ada-france.org/mailman/listinfo/comp.lang.ada > >