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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f891f,9d58048b8113c00f X-Google-Attributes: gidf891f,public X-Google-Thread: 101deb,b20bb06b63f6e65 X-Google-Attributes: gid101deb,public X-Google-Thread: 103376,2e71cf22768a124d X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,9d58048b8113c00f X-Google-Attributes: gid1014db,public X-Google-Thread: 10cc59,9d58048b8113c00f X-Google-Attributes: gid10cc59,public From: bn@alsys.com (Brian Nettleton @pulsar) Subject: Re: next "big" language?? (disagree) Date: 1996/06/25 Message-ID: #1/1 X-Deja-AN: 162158057 sender: news@thomsoft.com (USENET News Admin @flash) x-nntp-posting-host: pulsar references: <4q707h$1r2@krusty.irvine.com> organization: Thomson Software Products, San Diego, CA, USA newsgroups: comp.lang.pascal,comp.lang.c,comp.lang.misc,comp.lang.pl1,comp.lang.ada Date: 1996-06-25T00:00:00+00:00 List-Id: In dewar@cs.nyu.edu (Robert Dewar) writes: >In GNAT, > pragma Assert (X); >means EXACTLY > if not X then > raise Assert_Error; > end if; >which is well defined, but not at all in the category of assertions that >the compiler can take advantage of, which can behave in a completely >differrent (and possibly suprising manner). >For instance, another view of assertions is exemplified by the following: > pragma Assert (X /= 0); > ... > Q := 30 / X; >where the compiler "knows" that X is non-zero, and therefore skips the >test for X being zero in the division, and consequently generates some >junk value in Q. In this model, assertions do not correspond to any >executable code. I'm not sure I see the complete distinction. Wouldn't it be possible for a compiler to eliminate any divide-by-zero check from the following code sequence: if not (X /= 0) then raise Assert_Error; end if; Q := 30 / X; The divide is unreachable when X = 0. Now this admittedly does cause a change in the generated code when an assertion is used. I'm trying to understand the "assertions should not affect things" camp. -Brian Nettleton