comp.lang.ada
 help / color / mirror / Atom feed
* GNAT CE 2019 bug: Predicate check not performed
@ 2020-04-19  9:28 AdaMagica
  2020-04-19 22:31 ` Anh Vo
  0 siblings, 1 reply; 14+ messages in thread
From: AdaMagica @ 2020-04-19  9:28 UTC (permalink / raw)


The problem is with GNAT CE 2019.
GNAT CE 2018 was correct.
------------------------------------------------
with Ada.Text_IO;
use  Ada.Text_IO;
with Ada.Assertions;
use  Ada.Assertions;

procedure Ass is

  pragma Assertion_Policy (Check);

  subtype String_5 is String with Dynamic_Predicate => String_5'First = 5;

  procedure P (X: String_5) is
  begin
    Put_Line ("P expects 5:" & X'First'Image);
  end P;

  procedure Q (X: String) is
  begin
    P (X);  -- Why no predicate check here?
  end Q;

  S: constant String := "Lady Ada";

begin

  begin
    Q (S);  -- prints 1, expected Assertion_Error
    Put_Line ("Problem Q: Assertion_Error not raised.");
  exception
    when Assertion_Error => Put_Line ("Q: Assertion_Error raised as expected.");
  end;

  begin
    P (S);  -- Assertion_Error raised here
    Put_Line ("Problem P: Assertion_Error not raised.");
  exception
    when Assertion_Error => Put_Line ("P: Assertion_Error raised as expected.");
  end;

end Ass;
---------------------
Result GNAT CE 2018
C:\Users\Grein\Documents\Christoph\Ada\Spielplatz\ausprobieren.exe
Q: Assertion_Error raised as expected.
P: Assertion_Error raised as expected.
[2020-04-18 19:33:34] process terminated successfully, elapsed time: 07.47s
Result GNAT CE 2019
C:\Users\Grein\Documents\Christoph\Ada\Spielplatz\ausprobieren.exe
P expects 5: 1
Problem Q: Assertion_Error not raised.
P: Assertion_Error raised as expected.
[2020-04-18 19:58:20] process terminated successfully, elapsed time: 04.25s

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

end of thread, other threads:[~2020-04-27  6:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19  9:28 GNAT CE 2019 bug: Predicate check not performed AdaMagica
2020-04-19 22:31 ` Anh Vo
2020-04-19 22:32   ` Anh Vo
2020-04-20 10:04     ` AdaMagica
2020-04-20 20:25       ` Anh Vo
2020-04-21  0:53         ` AdaMagica
2020-04-21  2:59           ` Anh Vo
2020-04-21  7:45             ` Simon Wright
2020-04-27  6:29               ` William J. Franck
2020-04-21  5:14           ` Per Sandberg
2020-04-21  7:34             ` AdaMagica
2020-04-21 16:04               ` Per Sandberg
2020-04-21  7:40           ` Simon Wright
2020-04-21 16:59             ` Optikos

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