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: 103376,bd9ca356defda48d X-Google-Attributes: gid103376,public From: mfb@mbunix.mitre.org (Michael F Brenner) Subject: Re: constraint-errors Date: 1996/10/07 Message-ID: <53bidr$en6@linus.mitre.org>#1/1 X-Deja-AN: 187371946 references: <538vgm$2o1@server.umt.edu> organization: The MITRE Corporation, Bedford Mass. newsgroups: comp.lang.ada Date: 1996-10-07T00:00:00+00:00 List-Id: : Can someone please give me some general advice on what causes : constraint-errors? :: Here are the most common causes: :: :: 1) Attempting to dereference a null pointer :: 2) Indexing beyond the end of an array :: 3) Choosing a field of the "wrong" variant of a record :: 4) Going outside the bounds of an integer range. :: 5) Forgetting to properly initialize a variable. Constraint errors are the largest difference in the FEEL of programming Ada versus other languages, and all programmers experience them, in part because of compiler/runtime/system problems, and in part because the programmers are being caught inserting bugs into their programs. Some of us believe that programmer insertion is the main source of bugs, and therefore, Ada's ability to catch them is a significant advantage. Some additional common causes of constraint errors are the following: 6) running out of memory at run-time 7) not explicitly sliding an array (occurs much less in Ada 95) 8) dereferencing a pointer that is not memory mapped to real memory 9) dereferencing a pointer to non-existent virtual memory 10) taking the square root of -1 11) dividing by zero 12) taking the arctangent of (0, 0) 13) taking the logarithm of a negative real number 14) giving an invalid code to the floating point unit 15) moving a small array or string into a big array or string 16) moving a big array or string into a small array or string 17) using a subtype or type that has no element past the beginning or end 18) proceeding in a loop, going one item past the end of the subtype 19) invoking a run-time routine that fails 20) invoking an operating system call that fails 21) executing the Ada statement: RAISE CONSTRAINT_ERROR and many others