Compiling the attached code, with the options used via "make check-acats", results in $ gnatmake -gnatws -O2 c732b01.adb gcc -c -gnatws -O2 c732b01.adb +===========================GNAT BUG DETECTED==============================+ | 7.1.0 (x86_64-apple-darwin15) GCC error: | | in begin_subprog_body, at ada/gcc-interface/utils.c:3297 | | Error detected at f732b00.ads:153:9 | | Please submit a bug report; see https://gcc.gnu.org/bugs/ . | | 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 command that you entered. | | Also include sources listed below. | +==========================================================================+ 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). c732b01.adb f732b00.ads report.ads compilation abandoned gnatmake: "c732b01.adb" compilation error -O1 gives the same ICE, -O0 or no -O flag results in $ gnatmake -gnatws -O0 c732b01.adb gcc -c -gnatws -O0 c732b01.adb gcc -c -gnatws -O0 f732b00.adb raised CONSTRAINT_ERROR : erroneous memory access gnatmake: "f732b00.adb" compilation error lockheed:c732b01 simon$ gnatmake -gnatws c732b01.adb gcc -c -gnatws f732b00.adb raised CONSTRAINT_ERROR : erroneous memory access gnatmake: "f732b00.adb" compilation error
Created attachment 41368 [details] Reproducer
Also fails with GNAT GPL 2016.
Already fixed on mainline.
Author: ebotcazou Date: Wed May 17 12:51:00 2017 New Revision: 248152 URL: https://gcc.gnu.org/viewcvs?rev=248152&root=gcc&view=rev Log: PR ada/80784 Backport from mainline 2017-05-02 Ed Schonberg <schonberg@adacore.com> * exp_ch3.adb (Freeze_Type): Do not generate an invariant procedure body for a local (sub)type declaration within a predicate function. Invariant checks do not apply to these, and the expansion of the procedure will happen in the wrong scope, leading to misplaced freeze nodes. Modified: branches/gcc-7-branch/gcc/ada/ChangeLog branches/gcc-7-branch/gcc/ada/exp_ch3.adb
.
*** Bug 80790 has been marked as a duplicate of this bug. ***