public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/42974] New: Array slice assignment is missing bounds checking for the source array
@ 2010-02-05 15:23 tero dot koskinen at iki dot fi
0 siblings, 0 replies; only message in thread
From: tero dot koskinen at iki dot fi @ 2010-02-05 15:23 UTC (permalink / raw)
To: gcc-bugs
GNAT does not generate dynamic/runtime bounds checking for array slice
assignment.
Following code should raise exception (but it doesn't):
-- gnatmake -gnatf -gnato testcase.adb
procedure Testcase is
type Element_Access is access all Integer;
type Element_Array is
array (Positive range <>) of Integer;
type Element_Array_Access is access all Element_Array;
A : Element_Array_Access := null;
B : Element_Array_Access := null;
begin
A := new Element_Array (1 .. 10);
A.all := (1,2,3,4,5,6,7,8,9,10);
B := new Element_Array (Positive'First .. Positive'First + 20);
B.all (Positive'First .. Positive'First + 15)
:= A.all (A.all'First .. A.all'First + 15);
end Testcase;
Two other commercial compilers raise exception when the program is run, but
GNAT doesn't.
Tested versions:
GNAT 4.3.2 on Debian GNU/Linux 5.0/stable (i386)
GNAT 4.4.2 on Fedora 12 (i386)
GNAT 4.2.4 on Ubuntu 8.04 (i386)
GNAT GPL 2009 on Windows XP (i386)
Example output from those commercial compilers:
-- first compiler
[C:\koodi\ada\buffer]testcase
** Unhandled CONSTRAINT_ERROR
Index or Subtype out of bounds - Pos of Error Value = 16
On Line Number 16 In TESTCASE
[C:\koodi\ada\buffer]
-- second compiler
[C:\koodi\ada\buffer]testcase
Ada-runtime: Exception CONSTRAINT_ERROR raised in
c:/koodi/ada/buffer/testcase.adb on line 16.
Bad bounds: 1..16 not in 1..10.
[C:\koodi\ada\buffer]
--
Summary: Array slice assignment is missing bounds checking for
the source array
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tero dot koskinen at iki dot fi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42974
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-02-05 15:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-05 15:23 [Bug ada/42974] New: Array slice assignment is missing bounds checking for the source array tero dot koskinen at iki dot fi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).