https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86100
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |anlauf at gcc dot gnu.org --- Comment #2 from anlauf at gcc dot gnu.org --- The problem seems to generally occur for class components of derived types. program p implicit none type t integer :: i = 0 end type t type any_matrix class(t), allocatable :: m(:,:) end type any_matrix type(any_matrix) :: a, b allocate(a%m(3,4)) call foo () contains subroutine foo () b = a ! Array bound mismatch for dimension 1 of array '<<unknown>>' (12/3) !b%m = a%m ! no runtime error with -fcheck=bounds end subroutine foo end This fails as indicated. Note that 12=3*4 is the total size of the array, and 3 is the size of the first dimension, which - along with the '<<unknown>>' - points to gfc_copy_class_to_class: from_len = gfc_conv_descriptor_size (from_data, 1); from_len = fold_convert (TREE_TYPE (orig_nelems), from_len); tmp = fold_build2_loc (input_location, NE_EXPR, logical_type_node, from_len, orig_nelems); msg = xasprintf ("Array bound mismatch for dimension %d " "of array '%s' (%%ld/%%ld)", 1, name); gfc_trans_runtime_check (true, false, tmp, &body, &gfc_current_locus, msg, fold_convert (long_integer_type_node, orig_nelems), fold_convert (long_integer_type_node, from_len)); So we compare dimension 1 and the full size of the rhs? Shouldn't we compare lhs and rhs shapes?