]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Incorrect expansion of VADS Size attribute applied to an array type
authorGary Dismukes <dismukes@adacore.com>
Fri, 5 Sep 2025 20:58:54 +0000 (20:58 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 19 Sep 2025 09:26:09 +0000 (11:26 +0200)
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

index e08dc42d903d4c5a60d25b10f13fb5f45ff2a8e6..bde4d40dcb538754dfdf300722033af704c039aa 100644 (file)
@@ -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;