comp.lang.ada
 help / color / mirror / Atom feed
* Change in GCC 5.1.0
@ 2015-04-26 16:51 Simon Wright
  2015-04-26 18:42 ` jan.de.kruyf
  2015-05-06 21:29 ` Randy Brukardt
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Wright @ 2015-04-26 16:51 UTC (permalink / raw)


GCC 4.9.1 (and presumably GNAT GPL 2014) allowed variable indexing on a
Set, even though there was no Variable_Indexing aspect in the spec.

GCC 5.1.0 doesn't.

So this code (from Gprbuild GPL 2014) compiled and, presumably, worked
when it shouldn't have:

   with Ada.Containers.Ordered_Sets;
   procedure Iteration is
      type Slave is new Integer;
      package Slave_S is new Ada.Containers.Ordered_Sets
        (Element_Type => Slave);
      Pool : Slave_S.Set;
      procedure Iterate (Proc : access procedure (S : in out Slave)) is
      begin
         for C in Pool.Iterate loop
            declare
               S : Slave := Slave_S.Element (C);
            begin
               Proc (S);
               Pool (C) := S;     -- <<<<<<<<<<<<<<< wrong
            end;
         end loop;
      end Iterate;
   begin
      null;
   end Iteration;

The thing about an (ordered) set is that replacing an element must
involve re-ordering the set, in case the element's position has
changed. So the compilable code in this case is

               Pool.Replace_Element (C, S);

That said, that looks awfully like tampering to me (if the order
changes, anyway). I await Gprbuild GPL 2015 with interest.

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

end of thread, other threads:[~2015-05-06 21:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 16:51 Change in GCC 5.1.0 Simon Wright
2015-04-26 18:42 ` jan.de.kruyf
2015-04-27  7:23   ` Dmitry A. Kazakov
2015-04-27  8:07     ` jan.de.kruyf
2015-05-06 21:29 ` Randy Brukardt

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