Bug 50502 - GNAT fails to compile a modification of B37101A ACATS test
Summary: GNAT fails to compile a modification of B37101A ACATS test
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 13.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-24 04:11 UTC by Tero Koskinen
Modified: 2023-10-17 16:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-06 00:00:00


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:11:47 UTC
GNAT shows its bug box when one tries to compile following procedure:
-- b37101a.adb
PROCEDURE B37101A IS

    TYPE ACC_STRING IS ACCESS string;

    FUNCTION F (S : acc_string) RETURN INTEGER IS
    BEGIN
         RETURN 1;
    END F;

    TYPE S IS RECORD
         C2 : INTEGER RANGE 1 .. F (NEW STRING (1 .. 3) );
    END RECORD;
BEGIN
   null;
END B37101A;

The above procedure is a modified version of B37101A ACATS test.

The error below:
$ gnatmake b37101a.adb 
gcc -c b37101a.adb
+===========================GNAT BUG DETECTED==============================+
| 4.6.0 20110603 (Red Hat 4.6.0-10) (i686-redhat-linux-gnu) Assert_Failure atree.adb:794|
| Error detected at b37101a.adb:11:37                                      |
| 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).

b37101a.adb

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


Extra info:
This is what happens with GNAT GPL 2011 (on Fedora Linux 15/i386):

$ gnatmake b37101a.adb
gcc -c b37101a.adb
b37101a.adb:11:37: subtype mark required in this context
b37101a.adb:11:37: found "S3B" declared at line 11
gnatmake: "b37101a.adb" compilation error
$

Janus/Ada can compile the code without errors (as expected).
Comment 1 Eric Botcazou 2015-12-06 14:22:35 UTC
Still fails on mainline.
Comment 2 simon 2019-01-17 21:10:17 UTC
OK (that is, this test code fails to compile for the expected reason,
rather than giving ICE) with 8.1.0 on x86_64-apple-darwin.

$ gnatmake -v b37101a.adb

GNATMAKE 8.1.0
Copyright (C) 1992-2018, Free Software Foundation, Inc.
  "b37101a.ali" being checked ...
  -> "b37101a.ali" missing.
gcc -c b37101a.adb
b37101a.adb:11:37: subtype mark required in this context
End of compilation
gnatmake: "b37101a.adb" Compilation error

In fact, it also succeeds with 4.8.1, & probably intermediate releases
too.

This may be down to the fact that the erroring line is (in 9.0.0)

   function Ekind (E : Entity_Id) return Entity_Kind is
   begin
      pragma Assert (Nkind (E) in N_Entity);          -- <<<<<<<<<<<
      return N_To_E (Nodes.Table (E + 1).Nkind);
   end Ekind;

i.e. an assertion which is disabled in release compilers, because it
ICEs in much the same way as the original with 9.0.0 20181103 & 20190115:

gcc -c b37101a.adb
+===========================GNAT BUG DETECTED==============================+
| 9.0.0 20190115 (experimental) (x86_64-apple-darwin15) Assert_Failure atree.adb:994|
| Error detected at b37101a.adb:11:37                                      |

HOWEVER! The real b37101a.adb, from ACATS 4.1, fails to compile for the 
expected reaons,

$ gnatmake -v b37101a.adb 

GNATMAKE 9.0.0 20190115 (experimental)
Copyright (C) 1992-2019, Free Software Foundation, Inc.
  "b37101a.ali" being checked ...
  -> "b37101a.ali" missing.
gcc -c b37101a.adb
b37101a.adb:61:24: discriminants must have a discrete or access type
b37101a.adb:63:24: discriminants must have a discrete or access type
etc etc
Comment 3 simon 2023-10-17 13:52:58 UTC
The sample compiles without error with GCC 13.1.0 and 14.0.0 20231008.

Close as fixed?
Comment 4 Eric Botcazou 2023-10-17 16:23:44 UTC
Indeed, thanks for spotting it.