Bug 14543 - [3.3 regression] Storage_Error on null slice
Summary: [3.3 regression] Storage_Error on null slice
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.3.2
: P2 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-12 02:44 UTC by Björn Persson
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Björn Persson 2004-03-12 02:44:17 UTC
This program, when compiled with Gnat 3.3.2 and run on Fedora Core 1, raises
Storage_Error on line 7 (because of a segmentation fault):

procedure Null_Slice_Error is             --  1
                                          --  2
   procedure Proc (NullS : String) is     --  3
      type SA is access String;           --  4
      Point : SA := new String (1 .. 0);  --  5
   begin                                  --  6
      Point.all := NullS;                 --  7
   end Proc;                              --  8
                                          --  9
   S : String := "s";                     -- 10
begin                                     -- 11
   Proc(S(3 .. 1));                       -- 12
end Null_Slice_Error;                     -- 13

If I change 3 to 2 on line 12 there is no error.

$ gnatmake null_slice_error
gcc -c null_slice_error.adb
gnatbind -x null_slice_error.ali
gnatlink null_slice_error.ali
$ ./null_slice_error

raised STORAGE_ERROR : stack overflow (or erroneous memory access)
$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)

I have been told that the same bug occurs in Gnat 3.3.3 on Debian, but not in
GCC 3.1 (1252) on Mac OS X and not in Gnat 3.15p on an unspecified OS. I tried
to check with the 3.4-20040310 snapshot, but I had to give up on that. Sorry.
Comment 1 Björn Persson 2004-03-12 22:57:16 UTC
Subject: Re:  New: Storage_Error on null slice, might be a
 regression.

Forwarded comments from comp.lang.ada:


Manuel Collado wrote:

 > I've reproduced the bug with the DJGPP port of gcc 3.3.3
 >
 > F:\PRUEBAS\ADA>gcc --version
 > gcc.exe (GCC) 3.3.3
 > Copyright (C) 2003 Free Software Foundation, Inc.
 > This is free software; see the source for copying conditions.  There 
is NO
 > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.
 >
 > F:\PRUEBAS\ADA>gnatmake null_slice_error
 > gcc -c null_slice_error.adb
 > null_slice_error.adb:1:11: warning: file name does not match unit name,
 > should be "nuslierr.adb"
 > gnatbind -x null_slice_error.ali
 > gnatlink null_slice_error.ali
 >
 > F:\PRUEBAS\ADA>F:\PRUEBAS\ADA\null_slice_error.exe
 > Exiting due to signal SIGSEGV
 > General Protection Fault at eip=000018fa
 > ....


Florian Villoing wrote:

 > It seems to be OK on FreeBSD 5.2 with gcc-3.4 compiled from sources :
 >
 > villoing:~/test$ gcc -v
 > Reading specs from 
/usr/home/villoing/install/gcc/bin/../lib/gcc/i386-unknown-freebsd5.2/3.4.0/specs
 > Configured with: ../gcc/configure --prefix=/home/villoing/install/gcc
 > --disable-shared --with-libiconv-prefix=/usr/local/lib
 > --disable-werror --enable-languages=c,ada
 > Thread model: posix
 > gcc version 3.4.0 20040305 (prerelease)
 >
 >
 >
 > villoing:~/test$ gnatmake -f -gnatv error.adb
 > gcc -c -gnatv error.adb
 >
 > GNAT 3.4.0 20040305 (prerelease) Copyright 1992-2004 Free Software
 > Foundation, Inc.
 >
 > Compiling: error.adb (source file time stamp: 2004-03-12 16:11:18)
 >  15 lines: No errors
 > gnatbind -x error.ali
 > gnatlink error.ali
 >
 >
 >
 > villoing:~/test$ ./error
 > villoing:~/test

Comment 2 Andrew Pinski 2004-03-12 23:10:10 UTC
Ada bugs which are fixed in 3.4.0 are not going to be fixed in 3.3.4 so closing.