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).
Still fails on mainline.
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
The sample compiles without error with GCC 13.1.0 and 14.0.0 20231008. Close as fixed?
Indeed, thanks for spotting it.