[Bug fortran/24305] New: Fortran function parameters tagged with the VALUE attribute are not passed by value by GDB

richard.bunt at arm dot com sourceware-bugzilla@sourceware.org
Tue Mar 5 14:28:00 GMT 2019


https://sourceware.org/bugzilla/show_bug.cgi?id=24305

            Bug ID: 24305
           Summary: Fortran function parameters tagged with the VALUE
                    attribute are not passed by value by GDB
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
          Assignee: unassigned at sourceware dot org
          Reporter: richard.bunt at arm dot com
  Target Milestone: ---

Note: This bug report is only valid if and when
https://sourceware.org/ml/gdb-patches/2019-01/msg00448.html enters GDB HEAD.
I'm raising a report preemptively so that there's a bug number for the test
case.

Fortran allows function parameters to be tagged with a "value" attribute which
indicates that an argument is to be passed by value, rather than the default
of by reference. For example:


integer(kind=4) function one_arg_value(x)
    integer(kind=4), value :: x
    one_arg_value = x
end function

p one_arg_value(10)
$19 = 6318016

Garbage is returned when this function is called with a version of GDB which
has this patch applied. Most likely this is the location of 10 in the inferior
placed into a 4-byte integer, since GDB is passing a pointer to this value
rather than the value. NOTE: This use case will work on GDB without this patch
applied, as it flips the default calling convention to that outlined in 
https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html. This
way functions calls will mostly work out of the box rather than mostly not
work.

If this function call was working as expected it would return 10.

This was tested with:
* A build of 36c25ffa1ab5d6d5ee0fa3fc32f128a58e78e7a2 + the following patch 
from the mailing list
https://sourceware.org/ml/gdb-patches/2019-01/msg00448.html
* On Ubuntu 16.04.
* On x86 64.
* Fortran programs compiled with GCC 8.2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list