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

* Re: GNAT CE 2019 bug: Predicate check not performed
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Anh Vo @ 2020-04-19 22:31 UTC (permalink / raw)


On Sunday, April 19, 2020 at 2:28:18 AM UTC-7, AdaMagica wrote:
> 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

It takes time to look thru the LRM to if this behavior is expected or not. However if String_5 is changed to type and lines 19 and 34 are adjusted for compilation, then it behaves as in GNAT CE 2018. By the way, GNAT Community 2019 on Windows 10 is for this check.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-19 22:31 ` Anh Vo
@ 2020-04-19 22:32   ` Anh Vo
  2020-04-20 10:04     ` AdaMagica
  0 siblings, 1 reply; 14+ messages in thread
From: Anh Vo @ 2020-04-19 22:32 UTC (permalink / raw)


On Sunday, April 19, 2020 at 3:31:15 PM UTC-7, Anh Vo wrote:
> On Sunday, April 19, 2020 at 2:28:18 AM UTC-7, AdaMagica wrote:
> > 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
> 
> It takes time to look thru the LRM to if this behavior is expected or not. However if String_5 is changed to type and lines 19 and 34 are adjusted for compilation, then it behaves as in GNAT CE 2018. By the way, GNAT Community 2019 on Windows 10 is for this check.

It takes time to look thru the LRM to see if...

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-19 22:32   ` Anh Vo
@ 2020-04-20 10:04     ` AdaMagica
  2020-04-20 20:25       ` Anh Vo
  0 siblings, 1 reply; 14+ messages in thread
From: AdaMagica @ 2020-04-20 10:04 UTC (permalink / raw)


Am Montag, 20. April 2020 00:32:37 UTC+2 schrieb Anh Vo:
> It takes time to look thru the LRM to see if...

RM 11.4.2(10.2/3) ... A pragma Assertion_Policy given in a declarative_part or ... applies from the place of the pragma to the end of the innermost enclosing declarative region. ...

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-20 10:04     ` AdaMagica
@ 2020-04-20 20:25       ` Anh Vo
  2020-04-21  0:53         ` AdaMagica
  0 siblings, 1 reply; 14+ messages in thread
From: Anh Vo @ 2020-04-20 20:25 UTC (permalink / raw)


On Monday, April 20, 2020 at 3:04:47 AM UTC-7, AdaMagica wrote:
> Am Montag, 20. April 2020 00:32:37 UTC+2 schrieb Anh Vo:
> > It takes time to look thru the LRM to see if...
> 
> RM 11.4.2(10.2/3) ... A pragma Assertion_Policy given in a declarative_part or ... applies from the place of the pragma to the end of the innermost enclosing declarative region. ...

I read this section and other related paragraphs. I could not any where that confirms this behavior. Therefore, I would suggest to send a bug report to report@adacore.com. 
 

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-20 20:25       ` Anh Vo
@ 2020-04-21  0:53         ` AdaMagica
  2020-04-21  2:59           ` Anh Vo
                             ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: AdaMagica @ 2020-04-21  0:53 UTC (permalink / raw)


Am Montag, 20. April 2020 22:25:23 UTC+2 schrieb Anh Vo:
> Therefore, I would suggest to send a bug report

I did, but since I'm not a supported customer, I won't get an answer.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  0:53         ` AdaMagica
@ 2020-04-21  2:59           ` Anh Vo
  2020-04-21  7:45             ` Simon Wright
  2020-04-21  5:14           ` Per Sandberg
  2020-04-21  7:40           ` Simon Wright
  2 siblings, 1 reply; 14+ messages in thread
From: Anh Vo @ 2020-04-21  2:59 UTC (permalink / raw)


On Monday, April 20, 2020 at 5:53:42 PM UTC-7, AdaMagica wrote:
> Am Montag, 20. April 2020 22:25:23 UTC+2 schrieb Anh Vo:
> > Therefore, I would suggest to send a bug report
> 
> I did, but since I'm not a supported customer, I won't get an answer.

Just use the work around by making String_5 as a new type of String (type String_5 is new String...). I am not sure if the fix will be in GNAT Community 2020 since this bug report is not early enough. It would be terrific if it is included in the upcoming release of GNAT Community 2020.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  0:53         ` AdaMagica
  2020-04-21  2:59           ` Anh Vo
@ 2020-04-21  5:14           ` Per Sandberg
  2020-04-21  7:34             ` AdaMagica
  2020-04-21  7:40           ` Simon Wright
  2 siblings, 1 reply; 14+ messages in thread
From: Per Sandberg @ 2020-04-21  5:14 UTC (permalink / raw)


Just tested with the latest supported GNAT and its fixed.
/P

On 4/21/20 2:53 AM, AdaMagica wrote:
> Am Montag, 20. April 2020 22:25:23 UTC+2 schrieb Anh Vo:
>> Therefore, I would suggest to send a bug report
> 
> I did, but since I'm not a supported customer, I won't get an answer.
> 

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  5:14           ` Per Sandberg
@ 2020-04-21  7:34             ` AdaMagica
  2020-04-21 16:04               ` Per Sandberg
  0 siblings, 1 reply; 14+ messages in thread
From: AdaMagica @ 2020-04-21  7:34 UTC (permalink / raw)


Am Dienstag, 21. April 2020 07:14:32 UTC+2 schrieb Per Sandberg:
> Just tested with the latest supported GNAT and its fixed.
> /P

I doubt it's fixed because of my report, too recent. But let's hope it will be correct again in GNAT CE 2020.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  0:53         ` AdaMagica
  2020-04-21  2:59           ` Anh Vo
  2020-04-21  5:14           ` Per Sandberg
@ 2020-04-21  7:40           ` Simon Wright
  2020-04-21 16:59             ` Optikos
  2 siblings, 1 reply; 14+ messages in thread
From: Simon Wright @ 2020-04-21  7:40 UTC (permalink / raw)


AdaMagica <christ-usch.grein@t-online.de> writes:

> Am Montag, 20. April 2020 22:25:23 UTC+2 schrieb Anh Vo:
>> Therefore, I would suggest to send a bug report
>
> I did, but since I'm not a supported customer, I won't get an answer.

I'm no supported, and I've had answers.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  2:59           ` Anh Vo
@ 2020-04-21  7:45             ` Simon Wright
  2020-04-27  6:29               ` William J. Franck
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Wright @ 2020-04-21  7:45 UTC (permalink / raw)


Anh Vo <anhvofrcaus@gmail.com> writes:

>  I am not sure if the fix will be in GNAT Community 2020 since this
> bug report is not early enough. It would be terrific if it is included
> in the upcoming release of GNAT Community 2020.

It's not fixed in FSF GCC 10 (as of gcc version 10.0.1 20200206; no
obviously-related changes since then)

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  7:34             ` AdaMagica
@ 2020-04-21 16:04               ` Per Sandberg
  0 siblings, 0 replies; 14+ messages in thread
From: Per Sandberg @ 2020-04-21 16:04 UTC (permalink / raw)



I tested against the 21.0w-20200305 version.
/P

On 4/21/20 9:34 AM, AdaMagica wrote:
> Am Dienstag, 21. April 2020 07:14:32 UTC+2 schrieb Per Sandberg:
>> Just tested with the latest supported GNAT and its fixed.
>> /P
> 
> I doubt it's fixed because of my report, too recent. But let's hope it will be correct again in GNAT CE 2020.
> 

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  7:40           ` Simon Wright
@ 2020-04-21 16:59             ` Optikos
  0 siblings, 0 replies; 14+ messages in thread
From: Optikos @ 2020-04-21 16:59 UTC (permalink / raw)


On Tuesday, April 21, 2020 at 2:40:13 AM UTC-5, Simon Wright wrote:
> AdaMagica <christ-usch.grein@t-online.de> writes:
> 
> > Am Montag, 20. April 2020 22:25:23 UTC+2 schrieb Anh Vo:
> >> Therefore, I would suggest to send a bug report
> >
> > I did, but since I'm not a supported customer, I won't get an answer.
> 
> I'm no supported, and I've had answers.

You effectively provide Mac support/service to GNAT.  You are not developing a directly or indirectly competing Ada-language nonGNAT product.  I am pretty sure that is why.

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

* Re: GNAT CE 2019 bug: Predicate check not performed
  2020-04-21  7:45             ` Simon Wright
@ 2020-04-27  6:29               ` William J. Franck
  0 siblings, 0 replies; 14+ messages in thread
From: William J. Franck @ 2020-04-27  6:29 UTC (permalink / raw)


On 2020-04-21 07:45:52 +0000, Simon Wright said:

> 
> It's not fixed in FSF GCC 10 (as of gcc version 10.0.1 20200206; no
> obviously-related changes since then)


Still not fixed in FSF gcc 10 master branch as on 2020-04-21

$ gnat -version
GNAT 10.0.1 20200421 (experimental)
Copyright 1996-2020, Free Software Foundation, Inc.

on MacOS 10.14.6

$./ass
P expects 5: 1
Problem Q: Assertion_Error not raised.
P: Assertion_Error raised as expected.


^ 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