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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #5 from anlauf at gcc dot gnu.org ---
The rank mismatch is detected with:

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 7adbf958aec..112874e53f6 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -1370,7 +1373,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
          gfc_find_vtab (&cons->expr->ts);

       if (cons->expr->expr_type != EXPR_NULL && rank != cons->expr->rank
-         && (comp->attr.allocatable || cons->expr->rank))
+         && (comp->attr.allocatable || comp->attr.pointer ||
cons->expr->rank))
        {
          gfc_error ("The rank of the element in the structure "
                     "constructor at %L does not match that of the "


This gives:

pr56423-z2.f90:7:8:

    7 |   z = t(x(2))
      |        1
Error: The rank of the element in the structure constructor at (1) does not
match that of the component (0/1)

in agreement with other brands.

Still missing: detection of invalid vector subscripts.

Reply via email to