This is the mail archive of the gcc-patches@gcc.gnu.org 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: avoid allocating too much stack for aggregate


Tested on x86-linux

Fix a SEGV when trying to allocate too much stack

pragma Initialize_Scalars;
procedure Initialize is
   type String_Access is access String;
   A : String_Access;
begin
   A := new String (1 .. 10_000_000);
end Initialize;

$ gnatmake initialize
$ initialize
should not SEGV

2004-10-26  Ed Schonberg  <schonberg@gnat.com>

	* exp_aggr.adb (Safe_Component): An aggregate component that is an
	unchecked conversion is safe for in-place use if the expression of the
	conversion is safe.
	(Expand_Array_Aggregate): An aggregate that initializes an allocator may
	be expandable in place even if the aggregate does not come from source.
	(Convert_Array_Aggr_In_Allocator): New procedure to initialize the
	designated object of an allocator in place, rather than building it
	first on the stack. The previous scheme forces a full copy of the array,
	and may be altogether unsusable if the size of the array is too large
	for stack allocation.

Attachment: difs.12
Description: Text document


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