public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/86100] Spurious error with -fcheck=bounds and allocatable class(*) array components Date: Wed, 08 May 2024 19:26:03 +0000 [thread overview] Message-ID: <bug-86100-4-vCsZ8cAlfi@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-86100-4@http.gcc.gnu.org/bugzilla/> 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?
next parent reply other threads:[~2024-05-08 19:26 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-86100-4@http.gcc.gnu.org/bugzilla/> 2024-05-08 19:26 ` anlauf at gcc dot gnu.org [this message] 2024-05-08 19:29 ` anlauf at gcc dot gnu.org 2024-05-13 20:30 ` anlauf at gcc dot gnu.org 2024-05-24 19:30 ` cvs-commit at gcc dot gnu.org 2024-05-25 18:50 ` cvs-commit at gcc dot gnu.org 2024-05-25 18:54 ` anlauf at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-86100-4-vCsZ8cAlfi@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).