https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123589

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> I've done some debugging and came up with this patch. I tested it with the
> latest version of trunk on x86_64-w64-mingw32 and it works fine, and seems
> to fix the bug. Of course given that I'm not super familiar with the GNAT
> codebase it's possible this is more of a bodge than a root cause fix, but
> I'll submit it just in case it's useful.

Thanks!  I think that "Has_Default_Aspect (Base)" would be slightly better,
although it's strictly equivalent because Has_Default_Aspect goes through
Base_Type internally (to be honest, the test Is_Public (Typ) looks bogus).

I'm going to test the following change for the sake of consistency:

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index af1b82d351d..df24be0a65a 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -5734,7 +5734,7 @@ package body Exp_Ch3 is
             --  and do not need initialization procedures.

             elsif Is_Standard_String_Type (Base)
-              and then No (Default_Aspect_Component_Value (Base))
+              and then not Has_Default_Aspect (Base)
             then
                null;

@@ -5764,6 +5764,7 @@ package body Exp_Ch3 is
       elsif (Present (Init_Proc (Component_Type (Base)))
               and then No (Base_Init_Proc (Base)))
         or else (Init_Or_Norm_Scalars and then Base = Typ)
+        or else Has_Default_Aspect (Base)
         or else Is_Public (Typ)
       then
          Build_Array_Init_Proc (Base, N);

Reply via email to