From b0f15d09da63effeb92d3d59f39bfab3c664bcaf Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Fri, 5 Sep 2025 20:58:54 +0000 Subject: [PATCH] ada: Incorrect expansion of VADS Size attribute applied to an array type The compiler fails, either with an Assert_Failure (for a compiler with assertions enabled) or by producing a bad value, when processing a VADS_Size attribute (or a Size attribute when pragma Use_VADS_Size is in force), in the case where the prefix denotes a composite type or subtype whose object size (Esise) is not known by the front end. The bug is due to Eval_Attribute attempting to fold a VADS-related size attribute even when Esize is not yet known for the type. gcc/ada/ChangeLog: * sem_attr.adb (Eval_Attribute): In the case of a VADS-specific size attribute, only fold to the object size when the Esize field is known. --- gcc/ada/sem_attr.adb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index e08dc42d903..bde4d40dcb5 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -10493,10 +10493,10 @@ package body Sem_Attr is Fold_Uint (N, Expr_Value (Expression (S)), Static); -- If no size is specified, then we simply use the object - -- size in the VADS_Size case (e.g. Natural'Size is equal - -- to Integer'Size, not one less). + -- size (when known) in the VADS_Size case (for example, + -- Natural'Size is equal to Integer'Size, not one less). - else + elsif Known_Esize (P_TypeA) then Fold_Uint (N, Esize (P_TypeA), Static); end if; end; -- 2.47.3