comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthewjheaney@earthlink.net>
Subject: Re: Ada.Containers.Indefinite_Ordered_Maps of gcc 4.0.1 has bug ?
Date: Sat, 06 Aug 2005 15:37:35 GMT
Date: 2005-08-06T15:37:35+00:00	[thread overview]
Message-ID: <uek97oz40.fsf@earthlink.net> (raw)
In-Reply-To: 42F4B753.2080004@panathenaia.halfmoon.jp

"Y.Tomino" <demoonlit@panathenaia.halfmoon.jp> writes:

> I send a-ciorma.ad? as attachments.
> (C:\mingw\lib\gcc\i686-pc-mingw32\4.0.1\adainclude\a-ciorma.ads,
>   C:\mingw\lib\gcc\i686-pc-mingw32\4.0.1\adainclude\a-ciorma.adb)
> 
> I built gcc 4.0.1 with "--enable-languages=c,ada,c++ --prefix=/mingw".


You appear to have an older version of the sources. Here's the problem:


   function Copy_Node (Source : Node_Access) return Node_Access is
      Target : constant Node_Access :=
         new Node_Type'(Parent  => null,
                        Left    => null,
                        Right   => null,
                        Color   => Source.Color,
                        Key     => Source.Key,
                        Element => Source.Element);
   begin
      return Target;
   end Copy_Node;


In this implementation of the indefinite container, keys and elements
are allocated.  The code fragment above simply copies the pointers, but
this is wrong, since Adjust must make its own copy.

This is an old bug, that was fixed a few months ago.  I'm surprised
you're seeing it.  You can simply patch your copy like this:

   function Copy_Node (Source : Node_Access) return Node_Access is
      K : Key_Access := new Key_Type'(Source.Key.all);
      E : Element_Access;
   begin
      E := new Element_Type'(Source.Element.all);

      return new Node_Type'(Parent  => null,
                            Left    => null,
                            Right   => null,
                            Color   => Source.Color,
                            Key     => K,
                            Element => E);
   exception
      when others =>
         Free_Key (K);
         Free_Element (E);
         raise;
   end Copy_Node;


Alternatively you can grab a copy of that module from the repository at
<http://charles.tigris.org/> .

I would submit a bug report either to the FSF or to AdaCore, to ensure
the fix wends its way to public GCC repositories.  This bug was found
and fixed in AdaCore's sources a while ago, so I don't understand why
you don't have the latest, corrected version.

-Matt



  parent reply	other threads:[~2005-08-06 15:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-06 11:57 Ada.Containers.Indefinite_Ordered_Maps of gcc 4.0.1 has bug ? Y.Tomino
2005-08-06 12:54 ` Matthew Heaney
2005-08-06 13:13   ` Y.Tomino
     [not found]   ` <42F4B753.2080004@panathenaia.halfmoon.jp>
2005-08-06 15:37     ` Matthew Heaney [this message]
2005-08-06 16:17       ` Y.Tomino
2005-08-06 16:33         ` Matthew Heaney
2005-08-06 16:49           ` Y.Tomino
replies disabled

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