This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/70870] Segmentation violation in gfc_assign_data_value


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

--- Comment #3 from kargl at gcc dot gnu.org ---
Index: data.c
===================================================================
--- data.c      (revision 238178)
+++ data.c      (working copy)
@@ -489,6 +489,15 @@ gfc_assign_data_value (gfc_expr *lvalue,
     }
   else
     {
+      if (lvalue->ts.type == BT_DERIVED
+         && gfc_has_default_initializer (lvalue->ts.u.derived))
+       {
+         gfc_error ("Nonpointer object %qs with default initialization "
+                    "shall not appear in a DATA statement at %L", 
+                    symbol->name, &lvalue->where);
+         return false;
+       }
+
       /* Overwriting an existing initializer is non-standard but usually only
         provokes a warning from other compilers.  */
       if (init != NULL)


% gfc -c -Wall a.f90
a.f90:6:4:

 data v2/t(2)/     ! this is wrong
    1
Error: Nonpointer object 'v2' with default initialization shall not appear in a
DATA statement at (1)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]