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: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: constraint-errors Date: 1996/10/07 Message-ID: #1/1 X-Deja-AN: 187336430 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: houdini.camb.inmet.com references: <538vgm$2o1@server.umt.edu> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-10-07T00:00:00+00:00 List-Id: Paul O Svelmoe (zingbust@selway.umt.edu) wrote: : Can someone please give me some general advice on what causes : constraint-errors? For 2 years I have been plagued by them every time I : try to do any programming at all in Ada. The only way I get by is by : continuing to try different things until something finally works, but I : never really understand what caused the crash in the first place. If you look in Chapter 11 of the Ada reference manual, you will find a list of causes of predefined exceptions (in the section entitled "Suppressing Checks" -- admittedly a non-intuitive place to look for this information). 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. There are other possibilities, but these are probably the most common. : ... Right : now I'm using a stack implemented as a linked list and a simple test : 'while not Is_Empty(sorted_stack)' is causing a constraing error. I know : you can't diagnose that particular error just from that but I really want : to try and gain insight into this thing. Can anyone point me in the right : direction? Thanks so much. If you are using linked lists, then by far the most common cause of a constraint_error is dereferencing a null pointer. In the above case, I suspect that "sorted_stack" is a null pointer, and Is_Empty doesn't check for that. : Paul Svelmoe : zingbust@selway.umt.edu -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA