http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49732
--- Comment #8 from Vorfeed Canal <vorfeed.canal at gmail dot com> 2011-07-14
14:43:49 UTC ---
It makes sense because patch which "fixes" the problem effectively removes the
information needed to do overflow check.
And now, when I know where to look is much smaller reproducer:
$ cat hello.adb
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C.Pointers;
procedure Hello is
function Create (Name : String) return size_t
is
type Name_String is new char_array (0 .. Name'Length);
type Name_String_Ptr is access Name_String;
pragma Controlled (Name_String_Ptr);
Name_Str : constant Name_String_Ptr := new Name_String;
Name_Len : size_t;
begin
To_C (Name, Name_Str.all, Name_Len);
return 1;
end Create;
Test : size_t;
begin
Test := Create("ABC");
end Hello;
$ gnatmake -O0 -gnato hello.adb
gcc -c -O0 -gnato hello.adb
raised STORAGE_ERROR : stack overflow (or erroneous memory access)
gnatmake: "hello.adb" compilation error