From: gautier_niouzes@hotmail.com
Subject: Re: fyi, GNAT and SPARK GPL 2016 are out
Date: Sat, 4 Jun 2016 09:13:30 -0700 (PDT)
Date: 2016-06-04T09:13:30-07:00 [thread overview]
Message-ID: <b7b10479-4cbe-49f8-8db4-29611b736cb3@googlegroups.com> (raw)
In-Reply-To: <nimo81$kjj$2@gioia.aioe.org>
Nice release - with new optimizations in the run-time library... and a nice banana skin. In some cases, an application working well with GNAT for years may crash with a nasty raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION - but only in a typical release mode; in a typical debug mode it works as before.
In a nutshell, if you are using Ada.Containers.*Maps, and have code like the P_KO procedure below, which is legal Ada 2005 & 2012, the executable will bomb when built with the -gnatp switch.
The cure is to use a cursor like in P_OK. It removes an exception part as well.
Is there an inclusion of pragma Suppress(Container_Checks) into the standard on its way ? Then the remarks such as A.18.4, 69/2 could be updated accordingly.
_________________________
Gautier's Ada programming
http://gautiersblog.blogspot.com/search/label/Ada
NB: follow the above link for a valid e-mail address
-----------8<-----------8<-----------8<-----------8<-------
-- GNAT GPL 2016 pragma, suppression included in -gnatp switch
pragma Suppress(Container_Checks);
with Ada.Strings.Unbounded.Hash; use Ada.Strings.Unbounded;
with Ada.Containers.Hashed_Maps;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_2016 is
package T_Dic is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Positive,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
dic: T_Dic.Map;
n: Positive:= 1;
procedure P_KO(s: String) is
i: Integer;
begin
i:= dic.Element(To_Unbounded_String(s));
Put_Line("Key found, element=" & Integer'Image(i));
exception
when Constraint_Error => -- A.18.4, 69/2
Put_Line("Key not found");
dic.Insert(To_Unbounded_String(s), n);
n:= n + 1;
end P_KO;
procedure P_OK(s: String) is
i: Integer;
use T_Dic;
curs: Cursor;
begin
curs:= dic.Find(To_Unbounded_String(s));
if curs = No_Element then
Put_Line("Key not found");
dic.Insert(To_Unbounded_String(s), n);
n:= n + 1;
else
i:= Element(curs);
Put_Line("Key found, element=" & Integer'Image(i));
end if;
end P_OK;
begin
P_OK("A");
P_OK("A");
P_KO("B");
P_KO("B");
end;
next prev parent reply other threads:[~2016-06-04 16:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-01 13:33 fyi, GNAT and SPARK GPL 2016 are out Nasser M. Abbasi
2016-06-01 22:22 ` daserlang
2016-06-02 12:56 ` mockturtle
2016-06-03 1:56 ` David Botton
2016-06-03 7:16 ` Simon Wright
2016-06-05 8:00 ` ahlan.marriott
2016-06-05 8:42 ` gautier_niouzes
2016-06-05 10:02 ` Simon Wright
2016-06-04 16:13 ` gautier_niouzes [this message]
2016-06-04 16:31 ` Georg Bauhaus
2016-06-04 18:35 ` gautier_niouzes
2016-06-04 19:34 ` Simon Wright
2016-06-05 9:38 ` gautier_niouzes
2016-06-05 7:14 ` Randy Brukardt
2016-06-04 17:36 ` Jeffrey R. Carter
2016-06-05 14:07 ` Alejandro R. Mosteo
2016-06-05 18:02 ` Jeffrey R. Carter
2016-06-05 7:12 ` Randy Brukardt
2016-06-04 21:15 ` ogpual
2016-06-04 21:49 ` Simon Wright
2016-06-04 23:02 ` ogpual
2016-06-05 17:57 ` Hadrien Grasland
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox