[gcc r15-10315] ada: Compiler crash on container aggregate association with nonstatic key choice
Eric Botcazou
ebotcazou@gcc.gnu.org
Thu Sep 11 10:36:42 GMT 2025
https://gcc.gnu.org/g:b97c46eebe72992ec4cc21df36b272ad431b92ca
commit r15-10315-gb97c46eebe72992ec4cc21df36b272ad431b92ca
Author: Gary Dismukes <dismukes@adacore.com>
Date: Thu Aug 21 18:48:12 2025 +0000
ada: Compiler crash on container aggregate association with nonstatic key choice
The compiler blows up on a container aggregate with a container element
association that has a key_choice given by a nonstatic key expression.
This happens in the size computation for the aggregate due to calling
Update_Choices with the nonstatic expression. The fix is simply to
condition the call to Update_Choices on whether the choice expression
is static.
gcc/ada/ChangeLog:
* exp_aggr.adb (Build_Container_Aggr_Code.Build_Size_Expr): In the case
of an association with a single choice, only call Update_Choices when
the choice expression is nonstatic.
Diff:
---
gcc/ada/exp_aggr.adb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index f0cf8393c7e1..f35e16b67616 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -6789,7 +6789,9 @@ package body Exp_Aggr is
-- Choice is a single discrete value
elsif Is_Discrete_Type (Etype (Choice)) then
- Update_Choices (Choice, Choice);
+ if Is_Static_Expression (Choice) then
+ Update_Choices (Choice, Choice);
+ end if;
Temp_Siz_Exp := Make_Integer_Literal (Loc, 1);
Set_Is_Static_Expression (Temp_Siz_Exp);
More information about the Gcc-cvs
mailing list