From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,NICE_REPLY_A,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Rod Kay Newsgroups: comp.lang.ada Subject: Re: Extra information in the message string of exceptions. Date: Sat, 29 Oct 2022 14:10:02 +1100 Organization: A noiseless patient Spider Message-ID: References: <3bc7a99c-d541-497b-b3fd-7a6db0ee0de9n@googlegroups.com> <574017e3-d354-41b9-87a1-1f3aa6edf4a2n@googlegroups.com> <371ba8ca-2304-4e8a-a77f-82548d706105n@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 29 Oct 2022 03:09:59 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="903a9aa28ae6585f7fa4018a74f4bc63"; logging-data="3526199"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vrcV17InzhaMa6ptMxd877vU7vsDTDx4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Cancel-Lock: sha1:IDzSdFd8I5ELND6dfxFQnRIY03Q= In-Reply-To: <371ba8ca-2304-4e8a-a77f-82548d706105n@googlegroups.com> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:64565 List-Id: On 29/10/22 11:35, Jerry wrote: > On Thursday, October 27, 2022 at 4:57:08 AM UTC-7, roda...@gmail.com wrote: >> On 8/6/22 19:08, Dmitry A. Kazakov wrote: >>> >>> I noticed that it requires a user-defined [sub]type AND nested subprogram: >>> >>> procedure Test (A : Integer) is >>> subtype T is Integer range 0 .. 42; >>> i : T; >>> begin >>> i := A; -- This will work >>> end; >>> begin >>> Test (-1); >>> >> Are you sure about this ? >> >> I tried ... >> >> >> procedure Example >> is >> X : Positive := 5; >> begin >> loop >> X := X - 1; >> end loop; >> end Example; >> >> >> ... with the -gnateE and saw this result ... >> >> >> [rod@orth example]$ ./example >> >> raised CONSTRAINT_ERROR : example.adb:6:14 range check failed >> value 0 not in 1..2147483647 >> [./example] >> 0x55916975377f Example at example.adb:6 >> 0x559169753b74 Main at b__example.adb:193 >> [/usr/lib/libc.so.6] >> 0x7f9230be728e >> 0x7f9230be7348 >> [./example] >> 0x559169753623 _start at start.S:115 >> 0xfffffffffffffffe > > So -gnateE works part of the time? > Jerry I've not tested this extensively but assume the extra info would be shown in most cases. One exception is the following ... procedure Example is X : Positive := 0 with Unreferenced; begin null; end Example; ... which shows a compile time warning ... gprbuild -d -P/home/rod/Desktop/sandbox/ada/example/example.gpr -XLace_Build_Mode=debug -XLace_Restrictions=xgc -XLace_OS=Linux -Xrestrictions=xgc Compile [Ada] example.adb example.adb:3:20: warning: value not in range of type "Standard.Positive" [enabled by default] example.adb:3:20: warning: Constraint_Error will be raised at run time [enabled by default] Bind [gprbind] example.bexch [Ada] example.ali Link [link] example.adb [2022-10-29 13:56:36] process terminated successfully, elapsed time: 00.60s ... and when run ... [rod@orth example]$ ./example raised CONSTRAINT_ERROR : example.adb:3 range check failed [./example] 0x560439f23710 Example at example.adb:3 0x560439f23b00 Main at b__example.adb:193 [/usr/lib/libc.so.6] 0x7f746d52928e 0x7f746d529348 [./example] 0x560439f23623 _start at start.S:115 0xfffffffffffffffe I'm a little surprised that the compiler shows a warning rather than an error but I suppose there must be some reason for that.