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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,2d40525238a7131e,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!l2g2000vbn.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Ada.Calendar.Formatting bug in GNAT? Date: Fri, 16 Sep 2011 12:55:55 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 83.3.40.82 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1316202955 23710 127.0.0.1 (16 Sep 2011 19:55:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 16 Sep 2011 19:55:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l2g2000vbn.googlegroups.com; posting-host=83.3.40.82; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21936 Date: 2011-09-16T12:55:55-07:00 List-Id: I have a problem with Ada.Calendar.Formatting.Image with the Duration parameter. As far as I understand 9.6.1, points 86.a/2: "Implementation defined: The result of Calendar.Formating.Image if its argument represents more than 100 hours." and 86.b/2: "Implementation Note: This cannot be implemented (directly) by calling Calendar.Formatting.Split, since it may be out of the range of Day_Duration, and thus the number of hours may be out of the range of Hour_Number." the Image function should cope with Durations longer than one day (but not longer than 100 hours) and Day_Duration should not be a limitation here. Let's try: with Ada.Calendar.Formatting; with Ada.Text_IO; procedure Test is Hour : constant Duration := 3_600.0; D_1 : constant Duration := 23 * Hour; D_2 : constant Duration := 25 * Hour; begin Ada.Text_IO.Put_Line (Ada.Calendar.Formatting.Image (D_1)); Ada.Text_IO.Put_Line (Ada.Calendar.Formatting.Image (D_2)); end Test; $ ./test 23:00:00 raised CONSTRAINT_ERROR : a-calfor.adb:381 explicit raise $ The a-calfor.adb:381 is a raise statement in: if not Seconds'Valid then raise Constraint_Error; end if; where Seconds is of type Day_Duration in function Split. Yes, the same Split which should not be used according to AARM. Is this a bug in the GNAT library? I think so. I have an additional question, though: why the constraints of Day_Duration were not detected at the point of call to Split, but rather later on with explicit test on Seconds'Valid? My understanding is that this should be checked at the point of call to Split, so that additional checks inside Split should not be necessary. A possible explanation is that the library was compiled with checks disabled and the explicit test was added to cover up for this, but maybe I'm missing something here. -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com