procedure array_test is Size : constant := 4; type Vector is array (Natural range <>) of Integer; type Matrix is array (Natural range <>, Natural range <>) of Integer; type Combined (Which : Natural) is record case Which is when 0 => V : Vector (1 .. Size * Size); when 1 => M : Matrix (1 .. Size, 1 .. Size); when others => null; end case; end record; V : constant Vector := [for I in 1 .. Size => I]; M : constant Combined := (Which => 0, V => for I in 1 .. Size * Size => I); begin null; end array_test; ⓘ Building matrix_test=0.1.0-dev/matrix_test.gpr... Compile [Ada] array_test.adb +===========================GNAT BUG DETECTED==============================+ | 13.2.1 20231014 (x86_64-pc-linux-gnu) Program_Error sem_util.adb:7351 explicit raise| | Error detected at array_test.adb:20:51 | | Compiling /home/laguest/src/mine-new/matrix_test/src/array_test.adb | | 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). /home/laguest/src/mine-new/matrix_test/src/array_test.adb compilation abandoned compilation of array_test.adb failed gprbuild: *** compilation phase failed error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/laguest/src/mine-new/matrix_test/matrix_test.gpr"] exited with code 4 error: Compilation failed. Compiled with -O2, that is the only flag.
Optimization is irrelevant, it"s an issue in the front-end.
Still fails on the mainline.
The code is actually invalid since an iterated_component_association is not an expression, so an error is in order. The correct syntax is: M : constant Combined := (Which => 0, V => (for I in 1 .. Size * Size => I));
For example: p.adb:20:51: error: missing intermediate array aggregate
The master branch has been updated by Marc Poulhi?s <dkm@gcc.gnu.org>: https://gcc.gnu.org/g:53133d07901afa45bd1cb3cdcf7f5d4ed2418dd7 commit r15-5241-g53133d07901afa45bd1cb3cdcf7f5d4ed2418dd7 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Mon Oct 28 11:19:10 2024 +0100 ada: Fix internal error on misplaced iterated component association This happens for example in the others choice of a 1-dimensional array: A : array (1 .. Length) of Integer := (others => for Each in 1 .. Length => Each); or when it is used without parentheses for the array component of a record. gcc/ada/ChangeLog: PR ada/112524 PR ada/113781 * par-ch4.adb (P_Primary) <Tok_For>: Give an error about missing parentheses in the (purported) iterated component case too. (P_Unparen_Cond_Expr_Etc): Likewise. * sem.adb (Analyze): Raise PE on N_Iterated_Component_Association. * sem_util.ads (Diagnose_Iterated_Component_Association): Delete. * sem_util.adb (Diagnose_Iterated_Component_Association): Likewise.
Fixed on the mainline.