This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Repair size overflow detection

Because of
size overflow detection is a little broken on the mainline and 4.3 branch.

Fixed by making the obvious adjustment, tested on i586-suse-linux, applied on 
the mainline and 4.3 branch.

2008-03-31  Eric Botcazou  <>

	* decl.c (gnat_to_gnu_entity) <object>: Do not force a non-null
	size if it has overflowed.

2008-03-31  Eric Botcazou  <>

	* gnat.dg/object_overflow.adb: New test.

Eric Botcazou
Index: decl.c
--- decl.c	(revision 133766)
+++ decl.c	(working copy)
@@ -640,8 +640,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	   clause, as we would lose useful information on the view size
 	   (e.g. for null array slices) and we are not allocating the object
 	   here anyway.  */
-	if (((gnu_size && integer_zerop (gnu_size))
-	     || (TYPE_SIZE (gnu_type) && integer_zerop (TYPE_SIZE (gnu_type))))
+	if (((gnu_size
+	      && integer_zerop (gnu_size)
+	      && !TREE_OVERFLOW (gnu_size))
+	     || (TYPE_SIZE (gnu_type)
+		 && integer_zerop (TYPE_SIZE (gnu_type))
+		 && !TREE_OVERFLOW (TYPE_SIZE (gnu_type))))
 	    && (!Is_Constr_Subt_For_UN_Aliased (Etype (gnat_entity))
 		|| !Is_Array_Type (Etype (gnat_entity)))
 	    && !Present (Renamed_Object (gnat_entity))
-- { dg-do compile }

procedure Object_Overflow is

  type Rec is null record;

  procedure Proc (x : Rec) is begin null; end;

  type Arr is array(Long_Integer) of Rec;
  Obj : Arr; -- { dg-warning "Storage_Error will be raised" }

  Proc (Obj(1));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]