comp.lang.ada
 help / color / mirror / Atom feed
* Leap second support and ARM 9.6.1p89/2
@ 2014-08-05 19:47 Natasha Kerensikova
  2014-08-07  4:57 ` Randy Brukardt
  0 siblings, 1 reply; 4+ messages in thread
From: Natasha Kerensikova @ 2014-08-05 19:47 UTC (permalink / raw)


Hello,

I've recently came across ARM 9.6.1p89/2 and tried the following
function to detect leap second at runtime:

   function Leap_Second_Support return Boolean is
      use Ada.Calendar;
      use Ada.Calendar.Time;

      Date : Time;
   begin
      begin
         Date := Time_Of
           (Year => 1990,
            Month => 12,
            Day => 31,
            Hour => 23,
            Minute => 59,
            Second => 59,
            Sub_Second => 0.5,
            Leap_Second => True,
            Time_Zone => 0);
      exception
         when Time_Error =>
            return False;
      end;

      declare
         Year : Year_Number;
         Month : Month_Number;
         Day : Day_Number;
         Hour : Hour_Number;
         Minute : Minute_Number;
         Second : Second_Number;
         Sub_Second : Second_Duration;
         Leap_Second : Boolean;
      begin
         Split
           (Date,
            Year, Month, Day,
            Hour, Minute, Second, Sub_Second,
            Leap_Second, 0);

         pragma Assert (Year = 1990);
         pragma Assert (Month = 12);
         pragma Assert (Day = 31);
         pragma Assert (Hour = 23);
         pragma Assert (Minute = 59);
         pragma Assert (Second = 59);
         pragma Assert (Leap_Second);
      end;

      return True;
   end Leap_Second_Support;

I was quite surprised to find that on my platforms (FSF GNAT 4.9.0 on
FreeBSD and FSF GNAT 4.8.3 on Fedora), the assertion testing Leap_Second
is raised, which means that Leap_Second is ignored instead of raising an
exception.

I realize that 9.6.1p89/2 is under "Implementation Advice", so I guess
that ignoring Leap_Second is allowed by the standard, right?
Should I still report it as a bug somewhere?

Can I just replace "pragma Assert (Leap_Second)" with "return False;" or
is it even more subtle? I don't see anything about the semantics for
systems without support for leap seconds, does it means it's undefined
behavior?


Thanks for your insights,
Natasha


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Leap second support and ARM 9.6.1p89/2
  2014-08-05 19:47 Leap second support and ARM 9.6.1p89/2 Natasha Kerensikova
@ 2014-08-07  4:57 ` Randy Brukardt
  2014-08-07  7:35   ` Natasha Kerensikova
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Brukardt @ 2014-08-07  4:57 UTC (permalink / raw)


"Natasha Kerensikova" <lithiumcat@instinctive.eu> wrote in message 
news:slrnlu2d6u.nrc.lithiumcat@nat.rebma.instinctive.eu...
...
> I was quite surprised to find that on my platforms (FSF GNAT 4.9.0 on
> FreeBSD and FSF GNAT 4.8.3 on Fedora), the assertion testing Leap_Second
> is raised, which means that Leap_Second is ignored instead of raising an
> exception.
>
> I realize that 9.6.1p89/2 is under "Implementation Advice", so I guess
> that ignoring Leap_Second is allowed by the standard, right?

The definition of Time_Of and Split is what matters here. I don't think it 
was intended that Leap_Second just be ignored. The Implementation Advice 
that you reference just means that it is OK to not support Leap_Seconds at 
all (but in that case, Time_Error ought to be raised by Time_Of).

> Should I still report it as a bug somewhere?

I would. I don't see any permission to ignore the Leap_Seconds flag (as 
opposed to just not supporting it). Perhaps your program ran afoul of 
rounding or something like that, but I'd let your implementer explain.

> Can I just replace "pragma Assert (Leap_Second)" with "return False;" or
> is it even more subtle? I don't see anything about the semantics for
> systems without support for leap seconds, does it means it's undefined
> behavior?

The Implementation Advice is attempting to explain that (the part about 
Split returning False and the other similar points). It shouldn't be 
undefined, because the behavior of Time_Of and the like are defined and 
should be followed regardless of what the target does.

                         Randy.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Leap second support and ARM 9.6.1p89/2
  2014-08-07  4:57 ` Randy Brukardt
@ 2014-08-07  7:35   ` Natasha Kerensikova
  2014-08-07  8:59     ` Markus Schöpflin
  0 siblings, 1 reply; 4+ messages in thread
From: Natasha Kerensikova @ 2014-08-07  7:35 UTC (permalink / raw)


Hello,

On 2014-08-07, Randy Brukardt <randy@rrsoftware.com> wrote:
> "Natasha Kerensikova" <lithiumcat@instinctive.eu> wrote in message 
> news:slrnlu2d6u.nrc.lithiumcat@nat.rebma.instinctive.eu...
> ...
>> I was quite surprised to find that on my platforms (FSF GNAT 4.9.0 on
>> FreeBSD and FSF GNAT 4.8.3 on Fedora), the assertion testing Leap_Second
>> is raised, which means that Leap_Second is ignored instead of raising an
>> exception.
>>
>> I realize that 9.6.1p89/2 is under "Implementation Advice", so I guess
>> that ignoring Leap_Second is allowed by the standard, right?
>
> The definition of Time_Of and Split is what matters here. I don't think it 
> was intended that Leap_Second just be ignored. The Implementation Advice 
> that you reference just means that it is OK to not support Leap_Seconds at 
> all (but in that case, Time_Error ought to be raised by Time_Of).

Thanks a lot for the language-lawyering explanation.

>> Should I still report it as a bug somewhere?
>
> I would. I don't see any permission to ignore the Leap_Seconds flag (as 
> opposed to just not supporting it). Perhaps your program ran afoul of 
> rounding or something like that, but I'd let your implementer explain.

Ok, so would I. So I guess the next step is checking who is the
implementer, i.e. whether's it's AdaCore's problem or FSF's.

Would someone here with a working installation of GNAT GPL 2014 be kind
enough to test the function in the OP, and tell me whether it's
affected?


Thanks for your help,
Natasha

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Leap second support and ARM 9.6.1p89/2
  2014-08-07  7:35   ` Natasha Kerensikova
@ 2014-08-07  8:59     ` Markus Schöpflin
  0 siblings, 0 replies; 4+ messages in thread
From: Markus Schöpflin @ 2014-08-07  8:59 UTC (permalink / raw)


Am 07.08.2014 09:35, schrieb Natasha Kerensikova:

> Ok, so would I. So I guess the next step is checking who is the
> implementer, i.e. whether's it's AdaCore's problem or FSF's.
>
> Would someone here with a working installation of GNAT GPL 2014 be kind
> enough to test the function in the OP, and tell me whether it's
> affected?

Can't say about GNAT GPL 2014, but I tested it with GNAT Pro 7.1.2 and a 
pre-release version of 7.3.0.

 > gnatmake -gnata -gnat05 -f test.adb
gcc -c -gnata -gnat05 test.adb
gnatbind -x test.ali
gnatlink test.ali
gnatlink: warning: executable name "test" may conflict with shell command
 > ./test

raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : test.adb:50

 > sed -n '50p' test.adb
          pragma ASSERT (LEAP_SECOND);

HTH, Markus

PS: Next time, please make sure that you post a full example which compiles, 
binds, and links correctly. Your code not only needs a main procedure, it also 
needs to with & use ADA.CALENDAR.FORMATTING instead of ADA.CALENDAR.TIME.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-07  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 19:47 Leap second support and ARM 9.6.1p89/2 Natasha Kerensikova
2014-08-07  4:57 ` Randy Brukardt
2014-08-07  7:35   ` Natasha Kerensikova
2014-08-07  8:59     ` Markus Schöpflin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox