public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102891] New: Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument
@ 2021-10-22  8:52 oeyvindyr at hotmail dot com
  2021-10-22 21:07 ` [Bug fortran/102891] " anlauf at gcc dot gnu.org
  2021-10-23 15:08 ` anlauf at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: oeyvindyr at hotmail dot com @ 2021-10-22  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102891
           Summary: Passing real part of complex type component using
                    w%z%re to a subroutine gives erroneous value of dummy
                    argument
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: oeyvindyr at hotmail dot com
  Target Milestone: ---

Created attachment 51653
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51653&action=edit
minimal fortran program

The attached minimal program prints the real part of a complex allocatable type
component in two ways: 1) "print*,w%z%re" in the caller 2) By passing w%z%re to
a subroutine that prints the array. The printed numbers are different in the
two cases, and it seems that the dummy argument in the called subroutine gets
an incorrect stride of 1, whereas it should be 2 for the real part of a complex
array.

Compiling with ifort gives the expected result and no warnings.

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

* [Bug fortran/102891] Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument
  2021-10-22  8:52 [Bug fortran/102891] New: Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument oeyvindyr at hotmail dot com
@ 2021-10-22 21:07 ` anlauf at gcc dot gnu.org
  2021-10-23 15:08 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-22 21:07 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2021-10-22

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

Interestingly, replacing the line

  call print_arr(w%z%re)

by

  call print_arr([w%z%re])

works around the issue.

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

* [Bug fortran/102891] Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument
  2021-10-22  8:52 [Bug fortran/102891] New: Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument oeyvindyr at hotmail dot com
  2021-10-22 21:07 ` [Bug fortran/102891] " anlauf at gcc dot gnu.org
@ 2021-10-23 15:08 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-10-23 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Adding to main the lines

  print *, size (transfer ( w%z%re ,[1.0_dp]))
  print *, size (transfer ([w%z%re],[1.0_dp]))

prints

           4
           2

whereas e.g.

  print *, size (transfer ( real (w%z, kind (w%z%re)) ,[1.0_dp]))
  print *, size (transfer ([real (w%z, kind (w%z%re))],[1.0_dp]))

prints

           2
           2

The issue is likely with the combination of array/array constructor and
the inquiry %re .

Possibly related: pr102599.

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

end of thread, other threads:[~2021-10-23 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22  8:52 [Bug fortran/102891] New: Passing real part of complex type component using w%z%re to a subroutine gives erroneous value of dummy argument oeyvindyr at hotmail dot com
2021-10-22 21:07 ` [Bug fortran/102891] " anlauf at gcc dot gnu.org
2021-10-23 15:08 ` 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).