diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 9e1a68aef12..eb552ea2637 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -7404,7 +7404,7 @@ package body Exp_Ch6 is
       --
       --  into
       --
-      --    return _anonymous_ : <return_subtype> := <expression>
+      --    return _anonymous_ : constant <return_subtype> := <expression>
 
       --  The expansion produced by Expand_N_Extended_Return_Statement will
       --  contain simple return statements (for example, a block containing
@@ -7436,6 +7436,7 @@ package body Exp_Ch6 is
             Obj_Decl : constant Node_Id :=
                          Make_Object_Declaration (Loc,
                            Defining_Identifier => Make_Temporary (Loc, 'R'),
+                           Constant_Present    => True,
                            Object_Definition   => Subtype_Ind,
                            Expression          => Relocate_Node (Exp));
 
diff --git a/gcc/ada/libgnat/s-secsta.adb b/gcc/ada/libgnat/s-secsta.adb
index 994485fd8ab..692133284ef 100644
--- a/gcc/ada/libgnat/s-secsta.adb
+++ b/gcc/ada/libgnat/s-secsta.adb
@@ -644,15 +644,17 @@ package body System.Secondary_Stack is
          --  calculated conservatively.
       end if;
 
+      --  Raise Storage_Error if the size has overflowed
+
+      if Storage_Size < 0 then
+         raise Storage_Error with "object too large";
+      end if;
+
       --  Round the requested size (plus the needed padding in case of
       --  over-alignment) up to the nearest multiple of the default
       --  alignment to ensure efficient access and that the next available
       --  Byte is always aligned on the default alignement value.
 
-      --  It should not be possible to request an allocation of negative
-      --  size.
-
-      pragma Assert (Storage_Size >= 0);
       Mem_Size := Round_Up (Storage_Size + Padding);
 
       if Sec_Stack_Dynamic then
diff --git a/gcc/ada/libgnat/s-secsta__cheri.adb b/gcc/ada/libgnat/s-secsta__cheri.adb
index b793d95fa45..bf6a33ffaba 100644
--- a/gcc/ada/libgnat/s-secsta__cheri.adb
+++ b/gcc/ada/libgnat/s-secsta__cheri.adb
@@ -673,10 +673,11 @@ package body System.Secondary_Stack is
          --  calculated conservatively.
       end if;
 
-      --  It should not be possible to request an allocation of negative
-      --  size.
+      --  Raise Storage_Error if the size has overflowed
 
-      pragma Assert (Storage_Size >= 0);
+      if Storage_Size < 0 then
+         raise Storage_Error with "object too large";
+      end if;
 
       --  Round the requested size (plus the needed padding in case of
       --  over-alignment) to ensure that the CHERI bounds length will be
