https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120140
Bug ID: 120140 Summary: generic type-bound procedure, defined assignment, and subarray reference Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: kargls at comcast dot net Target Milestone: --- Created attachment 61345 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61345&action=edit code demonstrating issue The attached code generates an error (and a duplicate!). I believe modules mod1 and mod2 implement the same desired behavior, but I lack a good understand of type-bound procedures. % gfcx -o z -fmax-errors=1 tbp_subarray.f90 tbp_subarray.f90:23:10: 23 | x([2,1]) = y([1,2]) | 1~~~~~~~~ Error: Nonallocatable variable must not be polymorphic in intrinsic assignment at (1) - check that there is a matching specific subroutine for '=' operator If I disable the error message with this patch diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index f03708efef7..74402f3cf5e 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -12462,10 +12462,11 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns) } else if (lhs->ts.type == BT_CLASS) { - gfc_error ("Nonallocatable variable must not be polymorphic in intrinsic " - "assignment at %L - check that there is a matching specific " - "subroutine for %<=%> operator", &lhs->where); - return false; +// gfc_error ("Nonallocatable variable must not be polymorphic in intrinsic " +// "assignment at %L - check that there is a matching specific " +// "subroutine for %<=%> operator", &lhs->where); +// return false; +//return true; } bool lhs_coindexed = gfc_is_coindexed (lhs); The code then compiles and executes with either mod1 or mod2 in the program foo.