------- Additional Comments From baldrick at free dot fr  2005-01-14 08:59 
-------
Subject: Re:  New: ACATS CXA4009, CXA4020 - valgrind detects bad code 
(overlapping memcpy)

Here is a much simplified version:

> gnatmake -s -g -O2 tt
> valgrind --tool=memcheck ./tt
==10048== Memcheck, a memory error detector for x86-linux.
==10048== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==10048== Using valgrind-2.3.0.CVS, a program supervision framework for 
x86-linux.
==10048== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==10048== For more details, rerun with: -v
==10048==
==10048== Source and destination overlap in memcpy(0x52BFDE84, 0x52BFDE85, 2)
==10048==    at 0x1B906815: memcpy (mac_replace_strmem.c:113)
==10048==    by 0x80496F9: ss(short, long, int, double,...) (ss.adb:5)
==10048==    by 0x804978C: _ada_tt (tt.adb:9)
==10048==    by 0x8049634: main (b~tt.adb:112)
==10048==
==10048== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 11 from 1)
==10048== malloc/free: in use at exit: 10280 bytes in 2 blocks.
==10048== malloc/free: 2 allocs, 0 frees, 10280 bytes allocated.
==10048== For a detailed leak analysis,  rerun with: --leak-check=yes
==10048== For counts of detected errors, rerun with: -v

package SS is

   type Super_String (Length : Positive) is record
      Data : String (1 .. Length);
   end record;

   procedure Slide (Source : in out Super_String);

end SS;

package body SS is

   procedure Slide (Source : in out Super_String) is
   begin
      Source.Data (1 .. Source.Length - 1) := Source.Data (2 .. Source.Length);
   end;

end SS;

with SS; use SS;

procedure TT is
   S : Super_String := (
     Length => 3,
     Data   => "ABC"
   );
begin
   Slide (S);
end;



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19419

Reply via email to