comp.lang.ada
 help / color / mirror / Atom feed
* Bad cursor, good cursor
@ 2017-03-27 16:56 Marius Amado-Alves
  2017-03-27 18:12 ` G.B.
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Amado-Alves @ 2017-03-27 16:56 UTC (permalink / raw)


Ada 2012 compiled with latest(?) free GNAT (20160515-19)

This breaks with a "bad cursor" error for Subthing_Maps.Element at line 7. But how can that be, if the cursor has just been vetted at line 6 as not No_Element, and there were no changes to the container meanwhile, not even navigation?

1   C := Thing.Find (Thing_ID);
2   if C = Thing_Maps.No_Element then
3      Thing.Insert (Thing_ID, Subthing_Maps.Empty_Map, C, Ok);
4   end if;
5   I := Subthing_Maps.Find (Thing_Maps.Element (C), Subthing_ID);
6   if I = Subthing_Maps.No_Element
7   or else Subthing_Maps.Element (I) = Preterred then
8      Thing.Update_Element (C, Add_Subthing'Access);
9   end if;

(Thing is a map of Subthing_Maps. C, I are cursors of these containers, respectively. The keys are Unbounded_String. The maps are Ordered_Maps.)

What might I be missing, language-wise? Or might it be a GNAT bug? Thanks.

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

end of thread, other threads:[~2017-03-27 22:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 16:56 Bad cursor, good cursor Marius Amado-Alves
2017-03-27 18:12 ` G.B.
2017-03-27 18:35   ` Marius Amado-Alves
2017-03-27 22:26     ` Randy Brukardt

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