public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110360] New: ABI issue with character,value dummy argument
@ 2023-06-21 18:52 anlauf at gcc dot gnu.org
  2023-06-21 20:44 ` [Bug fortran/110360] " anlauf at gcc dot gnu.org
                   ` (44 more replies)
  0 siblings, 45 replies; 46+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-06-21 18:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110360

            Bug ID: 110360
           Summary: ABI issue with character,value dummy argument
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

Consider:

program p
  implicit none
  integer :: a = 65
  call val (char(65))  ! OK
  call val (char(a))   ! random junk
contains
  subroutine val (c)
    character, value :: c
    print *, "by value: ", c
  end
end

This should print twice

 by value: A
 by value: A

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

https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html

The ABI does not (yet) state how to handle character of length > 1 or variable
length - we'll likely need to pass a pointer to a temporary - but as long as
the dummy has fixed length 1 we should pass the argument by value.

A related issue occurs for actual arguments that are allocatable scalars
(or pointers to scalars).

^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2023-08-16 20:18 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-21 18:52 [Bug fortran/110360] New: ABI issue with character,value dummy argument 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
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

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).