public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/91544] When initializing allocatable character array get "Error: size of variable 'A.0' is too large" Date: Mon, 09 May 2022 17:38:16 +0000 [thread overview] Message-ID: <bug-91544-4-lvvX36pM4c@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-91544-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91544 Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> --- Reconfirmed with GCC 13. Internally, the following code is generated (for my example, -fdump-tree-original): static character(kind=1) A.0[3][1:D.4246] = {"abcde", "fhji", "klmno"}; The problem is that D.4246 is a variable and not a constant. I think the proper solution is to create an array for max length, i.e. 5 in this example with right padding if too short: static character(kind=1) A.0[3][1:5] = {"abcde", "fhji ", "klmno"}; And then in the array use, there is already some code like the following. However, here, not only the .x (= desired length) but also the actual length (here: 5) has to be taken into account for the memmove/memset bit, i.e. min(.x, 5). (In the example below, .x, D.4251 and D.4252 are all the same - and match either the LHS after allocation or RHS of the assignment.) .x = i >= -2 ? (integer(kind=8)) (i + 2) : 0; ... D.4252 = .x; D.4253 = (void *) D.4242 + (sizetype) (((S.1 + D.4249) + D.4243) * x.span); D.4254 = (void *) &A.0[S.1]; if (D.4252 > 0) { if (NON_LVALUE_EXPR <D.4251> < NON_LVALUE_EXPR <D.4252>) { __builtin_memmove (D.4253, D.4254, (unsigned long) NON_LVALUE_EXPR <D.4251>); __builtin_memset (D.4253 + (sizetype) NON_LVALUE_EXPR <D.4251>, 32, (unsigned long) (NON_LVALUE_EXPR <D.4252> - NON_LVALUE_EXPR <D.4251>));
parent reply other threads:[~2022-05-09 17:38 UTC|newest] Thread overview: expand[flat|nested] mbox.gz Atom feed [parent not found: <bug-91544-4@http.gcc.gnu.org/bugzilla/>]
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-91544-4-lvvX36pM4c@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).