Bug 50503 - GNAT fails to compile a modification of B433001 ACATS test
Summary: GNAT fails to compile a modification of B433001 ACATS test
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-24 04:25 UTC by Tero Koskinen
Modified: 2015-12-06 14:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
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 Tero Koskinen 2011-09-24 04:25:18 UTC
GNAT bug box appears when compiling following procedure:
-- b433001.adb
with text_io; use text_io;
procedure B433001 is

  Rec_1 : constant integer := 5;

  type Test_Array_2 is array (Character range <>, Boolean range <>) of integer;

   O13: Test_Array_2('A'..'B',Boolean) :=
         ((Rec_1, others => <>), (Rec_1, others => <>));    -- bug box

  procedure put(x: test_array_2; c: character; b: boolean) is
  begin
        put_line(Integer'Image (x(c,b)));
        put_line(Integer'Image (x(c,b)));
        new_line;
  end put;

begin
  put(O13,'A',True);
  put(O13,'A',False);
  put(O13,'B',True);
  put(O13,'B',False);
end B433001;

The error:
$ gnatmake b433001
gcc -c b433001.adb
+===========================GNAT BUG DETECTED==============================+
| 4.6.0 20110603 (Red Hat 4.6.0-10) (i686-redhat-linux-gnu) Assert_Failure nlists.adb:177|
| Error detected at b433001.adb:10:10                                      |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc or gnatmake command that you entered.              |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

b433001.adb

compilation abandoned
gnatmake: "b433001.adb" compilation error
$

The system is Fedora Linux 15/i386.


GNAT GPL 2011 can compile the given file, but constraint error is (errorneously) raised at runtime:
$ gnatmake b433001.adb
gcc -c b433001.adb
b433001.adb:10:10: warning: too few elements for subtype of "Test_Array_2" defined at line 9
b433001.adb:10:10: warning: "Constraint_Error" will be raised at run time
gnatbind -x b433001.ali
gnatlink b433001.ali
$ ./b433001

raised CONSTRAINT_ERROR : b433001.adb:10 range check failed
$


When compiled with Janus/Ada, the b433001 procedure above runs without errors (as expected).
Comment 1 simon 2011-10-31 22:37:02 UTC
This works correctly (of course, it's vile code, so I had to spend a long time seeing what it was supposed to do)  with
gcc version 4.7.0 20111026 (experimental) [trunk revision 180524] (GCC) 
Target: x86_64-apple-darwin11
Comment 2 Eric Botcazou 2015-12-06 14:23:19 UTC
.