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/110360] ABI issue with character,value dummy argument Date: Thu, 22 Jun 2023 19:42:37 +0000 [thread overview] Message-ID: <bug-110360-4-HputX8MMrN@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110360-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110360 --- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to Mikael Morin from comment #4) > (In reply to anlauf from comment #0) > > but the second line contains junk, as the tree-dump shows: > > > > static void val (character(kind=1)[1:1], integer(kind=8)); > > static integer(kind=4) a = 65; > > > > val ("A", 1); > > { > > character(kind=1) char.1; > > > > char.1 = (character(kind=1)) a; > > val (&char.1, 1); > > } > > > > Clearly, the second case is inconsistent with the ABI, see the prototype, and > > > Yes, but it's not worse than the first one: "A" is a pointer, not a value. > I would say that it is the middle-end that is inconsistent here. Hmm. Have a look at the following: subroutine s implicit none interface subroutine val (c) character, value :: c end end interface call val ("A") call val ("ABCDEF") end Dump-tree: val ("A", 1); val ("ABCDEF", 6); I am not good at reading assembler, but it appears that "ABCDEF" is awfully copied (pushed?) on the stack. --> missed optimization. (I've played a little but didn't find a quick, working solution for the truncation, only some awful lengthy code. Will add a TODO in the patch.) Changing the interface to use "character, intent(in) :: c" produces what I assume is the ordinary by-reference. > Looks good. > I would suggest to create an overload that avoids duplicating the > build_int_cst (integer_type_node, 1) in several places. > Shouldn't it be build_int_cst (gfc_charlen_type_node, 1) by the way? That's true. I copied that from another snippet. It is not clear to me what you mean by "overload" here. Do you want to elaborate? I've also extended the testcase to sample most things that came to my mind, except for the [character, value, bind(c)] case. We'd better track this elsewhere.
next prev parent reply other threads:[~2023-06-22 19:42 UTC|newest] Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-21 18:52 [Bug fortran/110360] New: " anlauf at gcc dot gnu.org 2023-06-21 20:44 ` [Bug fortran/110360] " anlauf at gcc dot gnu.org 2023-06-21 20:56 ` anlauf at gcc dot gnu.org 2023-06-21 21:25 ` anlauf at gcc dot gnu.org 2023-06-21 21:25 ` anlauf at gcc dot gnu.org 2023-06-22 7:08 ` mikael at gcc dot gnu.org 2023-06-22 7:16 ` mikael at gcc dot gnu.org 2023-06-22 19:42 ` anlauf at gcc dot gnu.org [this message] 2023-06-22 20:24 ` anlauf at gcc dot gnu.org 2023-06-23 8:00 ` mikael at gcc dot gnu.org 2023-06-23 16:36 ` cvs-commit at gcc dot gnu.org 2023-06-23 20:14 ` anlauf at gcc dot gnu.org 2023-06-23 21:20 ` anlauf at gcc dot gnu.org 2023-06-24 18:23 ` anlauf at gcc dot gnu.org 2023-06-24 18:39 ` cvs-commit at gcc dot gnu.org 2023-06-25 18:45 ` anlauf at gcc dot gnu.org 2023-06-26 20:03 ` mikael at gcc dot gnu.org 2023-06-27 17:06 ` anlauf at gcc dot gnu.org 2023-06-27 17:57 ` anlauf at gcc dot gnu.org 2023-06-27 20:39 ` mikael at gcc dot gnu.org 2023-06-27 20:47 ` mikael at gcc dot gnu.org 2023-06-27 20:59 ` anlauf at gcc dot gnu.org 2023-06-28 9:17 ` mikael at gcc dot gnu.org 2023-06-28 18:56 ` anlauf at gcc dot gnu.org 2023-06-28 19:48 ` mikael at gcc dot gnu.org 2023-06-28 20:17 ` cvs-commit at gcc dot gnu.org 2023-07-15 18:24 ` dje at gcc dot gnu.org 2023-07-18 18:52 ` anlauf at gcc dot gnu.org 2023-07-28 15:54 ` dje at gcc dot gnu.org 2023-07-28 18:39 ` anlauf at gcc dot gnu.org 2023-07-28 19:00 ` dje at gcc dot gnu.org 2023-07-28 19:53 ` anlauf at gcc dot gnu.org 2023-07-28 21:15 ` dje at gcc dot gnu.org 2023-07-29 18:52 ` dje at gcc dot gnu.org 2023-07-29 20:05 ` anlauf at gcc dot gnu.org 2023-07-29 21:08 ` dje at gcc dot gnu.org 2023-07-29 21:43 ` anlauf at gcc dot gnu.org 2023-07-29 22:41 ` dje at gcc dot gnu.org 2023-07-30 20:52 ` anlauf at gcc dot gnu.org 2023-07-31 15:09 ` dje at gcc dot gnu.org 2023-08-14 20:11 ` cvs-commit at gcc dot gnu.org 2023-08-15 9:22 ` mikael at gcc dot gnu.org 2023-08-15 19:30 ` anlauf at gcc dot gnu.org 2023-08-16 8:42 ` mikael at gcc dot gnu.org 2023-08-16 20:02 ` cvs-commit at gcc dot gnu.org 2023-08-16 20:18 ` 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-110360-4-HputX8MMrN@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).