* Question about sets and expression @ 2017-05-08 15:53 reinert 2017-05-08 16:06 ` Robert Eachus 2017-05-08 19:00 ` Simon Wright 0 siblings, 2 replies; 12+ messages in thread From: reinert @ 2017-05-08 15:53 UTC (permalink / raw) Hi, I did not manage to make a simple test program for this problem, but maybe someone can give me a hint here. I start to be "blind" :-) os is here an Ordered_Set (not empty). The first part seems OK, but the second part is confusing (craches). ------------------------------------------------------------------------------- -- First part (seems OK): Put_Line(" Here A "); if not os.is_empty then Put_Line(" Here B "); c := os.first_element; else Put_Line(" Here C "); c := (id => Cnil, others => <>); end if; Put_Line(" Here D "); ------------------------------------------------------------------------------ -- Second part (here it goes wrong): c := (if not os.is_empty then os.first_element else (id => Cnil, others => <>)); Put_Line(" Here E "); ------------------------------------------------------------------------------ * Here is an example of output from this code: Here A Here B Here D Exception raised Exception name: STORAGE_ERROR Message: s-intman.adb:139 explicit raise reinert ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-08 15:53 Question about sets and expression reinert @ 2017-05-08 16:06 ` Robert Eachus 2017-05-08 17:03 ` reinert 2017-05-08 17:04 ` reinert 2017-05-08 19:00 ` Simon Wright 1 sibling, 2 replies; 12+ messages in thread From: Robert Eachus @ 2017-05-08 16:06 UTC (permalink / raw) On Monday, May 8, 2017 at 11:53:23 AM UTC-4, reinert wrote: > I did not manage to make a simple test program for this problem, > but maybe someone can give me a hint here. I start to be "blind" :-) > > os is here an Ordered_Set (not empty). The first part seems OK, > but the second part is confusing (craches). Trying to diagnose the problem without the declarations is difficult. I suspect that c := (id => Cnil, others => <>); is trying to assign an unbounded array with that others part. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-08 16:06 ` Robert Eachus @ 2017-05-08 17:03 ` reinert 2017-05-08 17:04 ` reinert 1 sibling, 0 replies; 12+ messages in thread From: reinert @ 2017-05-08 17:03 UTC (permalink / raw) On Monday, May 8, 2017 at 6:06:52 PM UTC+2, Robert Eachus wrote: > On Monday, May 8, 2017 at 11:53:23 AM UTC-4, reinert wrote: > > > I did not manage to make a simple test program for this problem, > > but maybe someone can give me a hint here. I start to be "blind" :-) > > > > os is here an Ordered_Set (not empty). The first part seems OK, > > but the second part is confusing (craches). > > Trying to diagnose the problem without the declarations is difficult. I suspect > that c := (id => Cnil, others => <>); is trying to assign an unbounded array with that others part. OK, sorry. c: cell_observation_t; where simply: type cell_observation_t is record id : cell_names1.target_t; state : cell_state_t := live; r, dr : real_vector2d := (0.0, 0.0); axis : degree_t; children1 : cell_names1.cell_names_sets.set := cell_names1.cell_names_sets.empty_set; pre_cell, next_cell : target_t := cnil; end record; "children1" is Ada.Containers.Ordered_Sets (without any defined bound): package cell_names_sets is new Ada.Containers.Ordered_Sets (target_t); "target_t" is an enumaration type. My hoped that someone has encountered similar with expressions and could give a hint. Maybe I have destroyed the Ordered_Set somewhere... I use GNAT under debian, updated. gnat-4.9. reinert ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-08 16:06 ` Robert Eachus 2017-05-08 17:03 ` reinert @ 2017-05-08 17:04 ` reinert 1 sibling, 0 replies; 12+ messages in thread From: reinert @ 2017-05-08 17:04 UTC (permalink / raw) On Monday, May 8, 2017 at 6:06:52 PM UTC+2, Robert Eachus wrote: > On Monday, May 8, 2017 at 11:53:23 AM UTC-4, reinert wrote: > > > I did not manage to make a simple test program for this problem, > > but maybe someone can give me a hint here. I start to be "blind" :-) > > > > os is here an Ordered_Set (not empty). The first part seems OK, > > but the second part is confusing (craches). > > Trying to diagnose the problem without the declarations is difficult. I suspect > that c := (id => Cnil, others => <>); is trying to assign an unbounded array with that others part. OK, sorry. c: cell_observation_t; where simply: type cell_observation_t is record id : cell_names1.target_t; state : cell_state_t := live; r, dr : real_vector2d := (0.0, 0.0); axis : degree_t; children1 : cell_names1.cell_names_sets.set := cell_names1.cell_names_sets.empty_set; pre_cell, next_cell : target_t := cnil; end record; "children1" is Ada.Containers.Ordered_Sets (without any defined bound): package cell_names_sets is new Ada.Containers.Ordered_Sets (target_t); "target_t" is an enumaration type. I hoped that someone has encountered similar with expressions and could give a hint. Maybe I have destroyed the Ordered_Set somewhere... I use GNAT under debian, updated. gnat-4.9. reinert ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-08 15:53 Question about sets and expression reinert 2017-05-08 16:06 ` Robert Eachus @ 2017-05-08 19:00 ` Simon Wright 2017-05-09 3:58 ` reinert 1 sibling, 1 reply; 12+ messages in thread From: Simon Wright @ 2017-05-08 19:00 UTC (permalink / raw) If you want help, you really need to provide a Minimal, Complete and Verifiable example[1]. [1] http://stackoverflow.com/help/mcve ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-08 19:00 ` Simon Wright @ 2017-05-09 3:58 ` reinert 2017-05-09 5:48 ` reinert 0 siblings, 1 reply; 12+ messages in thread From: reinert @ 2017-05-09 3:58 UTC (permalink / raw) On Monday, May 8, 2017 at 9:00:41 PM UTC+2, Simon Wright wrote: > If you want help, you really need to provide a Minimal, Complete and > Verifiable example[1]. > > [1] http://stackoverflow.com/help/mcve Will try. It could help me to make it if I knew expressions is just "syntactic sugar" or not. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 3:58 ` reinert @ 2017-05-09 5:48 ` reinert 2017-05-09 6:23 ` Niklas Holsti ` (3 more replies) 0 siblings, 4 replies; 12+ messages in thread From: reinert @ 2017-05-09 5:48 UTC (permalink / raw) Could anybody try this simple program below? I get the output (debian, gnat-4.9): -------------------------------------------------------------------------- ** A: ** B: raised PROGRAM_ERROR : test1b.adb:29 finalize/adjust raised exception -------------------------------------------------------------------------- Why "finalize/adjust raised exception" ? reinert https://korsnesbiocomputing.no/ with Ada.Numerics; use Ada.Numerics; with Ada.Numerics.Generic_Real_Arrays; with Ada.Containers.Ordered_Sets; with Text_IO;use Text_IO; procedure test1b is subtype real is Float; subtype degree_t is real range 0.0 .. 360.0; package gra is new Ada.Numerics.Generic_Real_Arrays (real); use gra; subtype real_vector2d is gra.real_vector (1 .. 2); type target_t is (cnil,C000,C001,C002,C003,C004); package cell_names_sets is new Ada.Containers.Ordered_Sets (target_t); type cell_state_t is (live, apoptosis, necrotic, dead, mitosis, mitotic_catastrophe, refusion, unknown, out_of_scene, ghost); type cell_observation_t is record id : target_t; state : cell_state_t := live; r, dr : real_vector2d := (0.0, 0.0); axis : degree_t; children1 : cell_names_sets.set := cell_names_sets.empty_set; pre_cell, next_cell : target_t := cnil; end record; function "<" (left, right : cell_observation_t) return Boolean is (left.id < right.id); function "=" (left, right : cell_observation_t) return Boolean is (left.id = right.id); package cell_observation_set is new Ada.Containers.Ordered_Sets (Element_Type => cell_observation_t); use cell_observation_set; os : cell_observation_set.set := to_set((id => C003,others => <>)); c : cell_observation_t; d : cell_observation_t := (id => Cnil,others => <>); begin Put_Line(" ** A: "); c := (if not os.is_empty then os.first_element else d); Put_Line(" ** B: "); c := (if not os.is_empty then os.first_element else (id => Cnil, others => <>)); Put_Line(" ** C "); end test1b; ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 5:48 ` reinert @ 2017-05-09 6:23 ` Niklas Holsti 2017-05-09 6:29 ` G.B. ` (2 subsequent siblings) 3 siblings, 0 replies; 12+ messages in thread From: Niklas Holsti @ 2017-05-09 6:23 UTC (permalink / raw) On 17-05-09 08:48 , reinert wrote: > Could anybody try this simple program below? > > I get the output (debian, gnat-4.9): > > -------------------------------------------------------------------------- > ** A: > ** B: > > raised PROGRAM_ERROR : test1b.adb:29 finalize/adjust raised exception > -------------------------------------------------------------------------- > Why "finalize/adjust raised exception" ? > [snip program code] On a Mac OS-X (10.8.5), GNAT GPL 2012 (20120509), options "-g -gnat2012", I get: ./test1b ** A: ** B: ** C with no exceptions. I haven't studied the program enough to opine on whether this is the correct expected result. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ . ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 5:48 ` reinert 2017-05-09 6:23 ` Niklas Holsti @ 2017-05-09 6:29 ` G.B. 2017-05-09 7:14 ` reinert 2017-05-09 9:28 ` gautier_niouzes 2017-05-09 11:15 ` Simon Wright 3 siblings, 1 reply; 12+ messages in thread From: G.B. @ 2017-05-09 6:29 UTC (permalink / raw) On 09.05.17 07:48, reinert wrote: > Could anybody try this simple program below? $ ./test1b ** A: ** B: ** C $ GNATMAKE GPL 2016 (20160515-49) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 6:29 ` G.B. @ 2017-05-09 7:14 ` reinert 0 siblings, 0 replies; 12+ messages in thread From: reinert @ 2017-05-09 7:14 UTC (permalink / raw) On Raspberry Pi (Raspbian up do date - which is much like debian) I get (similar to debian/gnat-4.9): ** A: ** B: raised PROGRAM_ERROR : test1b.adb:29 finalize/adjust raised exception Someone out there that also could try Raspberry Pi ? ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 5:48 ` reinert 2017-05-09 6:23 ` Niklas Holsti 2017-05-09 6:29 ` G.B. @ 2017-05-09 9:28 ` gautier_niouzes 2017-05-09 11:15 ` Simon Wright 3 siblings, 0 replies; 12+ messages in thread From: gautier_niouzes @ 2017-05-09 9:28 UTC (permalink / raw) No crash with GNAP GPL 2016 for Windows (gcc version 4.9.4 20160426 (for GNAT GPL 2016 20160515)). When elaborating a bit: ... begin Put_Line(" ** A: "); c1 := (if not os.is_empty then os.first_element else d); Put_Line(" ** B: "); c2 := (if not os.is_empty then os.first_element else (id => Cnil, others => <>)); Put_Line(" ** C "); if c1 = (id => C003,others => <>) then Put_Line(" ** c1 OK "); end if; if c2 = (id => C003,others => <>) then Put_Line(" ** c2 OK "); end if; end test1b; I get ** A: ** B: ** C ** c1 OK ** c2 OK The build command is: gnatmake -gnato -fno-inline -fstack-check -gnatVa -gnatecdebug.pra test1b.adb with debug.pra containing "pragma Initialize_Scalars;". Same result with "gnatmake -f -gnatpn test1b.adb" and "gnatmake -f -gnatpn -O2 test1b.adb". HTH Gautier ________________________________________________ Your daily dose of buzzwords: http://cbsg.sf.net ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Question about sets and expression 2017-05-09 5:48 ` reinert ` (2 preceding siblings ...) 2017-05-09 9:28 ` gautier_niouzes @ 2017-05-09 11:15 ` Simon Wright 3 siblings, 0 replies; 12+ messages in thread From: Simon Wright @ 2017-05-09 11:15 UTC (permalink / raw) reinert <reinkor@gmail.com> writes: > I get the output (debian, gnat-4.9): > > -------------------------------------------------------------------------- > ** A: > ** B: > > raised PROGRAM_ERROR : test1b.adb:29 finalize/adjust raised exception > -------------------------------------------------------------------------- > Why "finalize/adjust raised exception" ? I'm afraid this is a GNAT 4.9 error. On macOS Sierra, GCC 7.1.0 : OK GCC 6.1.0 : OK GCC 5.2.0 : OK GCC 4.9.1 : fails For amusement, GDB shows that it happens at a-crbtgo.adb:539: 538 procedure Generic_Clear (Tree : in out Tree_Type) is 539 Root : Node_Access := Tree.Root; 540 begin called from a-coorse.adb:1319: 1319 return It : constant Iterator := 1320 Iterator'(Limited_Controlled with 1321 Container => Container'Unrestricted_Access, 1322 Node => null); 1323 end Iterate; ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2017-05-09 11:15 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-05-08 15:53 Question about sets and expression reinert 2017-05-08 16:06 ` Robert Eachus 2017-05-08 17:03 ` reinert 2017-05-08 17:04 ` reinert 2017-05-08 19:00 ` Simon Wright 2017-05-09 3:58 ` reinert 2017-05-09 5:48 ` reinert 2017-05-09 6:23 ` Niklas Holsti 2017-05-09 6:29 ` G.B. 2017-05-09 7:14 ` reinert 2017-05-09 9:28 ` gautier_niouzes 2017-05-09 11:15 ` Simon Wright
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox