public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/59104] Wrong result with SIZE specification expression
Date: Wed, 22 May 2024 07:46:07 +0000	[thread overview]
Message-ID: <bug-59104-4-GQbL0h8zMg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59104-4@http.gcc.gnu.org/bugzilla/>

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
The problem lies in gfc_conv_expr_descriptor, as the following demonstrates:
module m1
   implicit none
   integer, parameter :: dp = kind([double precision::])
   contains
      function f(x)
         integer, intent(in) :: x
         real(dp) f(x/2)
         integer y(size(f)+1)

         write(*,*) 'size(f) = ',size(f)
         write(*,*) 'size(y) = ',my_size(y)
         f = 0
      end function f
      integer function my_size (arg)
        integer :: arg(:)
        my_size = size(arg)
      end
end module m1

program bug3
   use m1
   implicit none
   real y

   y = sum(f(2))
end program bug3

In both this and the original testcase, the result depends ultimately on a
'ubound.x' that has not been set.

I am not sure that I understand why explicit shape arrays are being handled
this way in size, when all the information needed is present in the array_spec.
However, the passing of an incorrect descriptor to 'my_size' has to be fixed.

Cheers

Paul

  parent reply	other threads:[~2024-05-22  7:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13  7:33 [Bug fortran/59104] New: " burnus at gcc dot gnu.org
2013-12-19 11:31 ` [Bug fortran/59104] " dominiq at lps dot ens.fr
2015-08-18  8:15 ` fxcoudert at gcc dot gnu.org
2022-01-24 21:57 ` anlauf at gcc dot gnu.org
2024-05-22  7:46 ` pault at gcc dot gnu.org [this message]
2024-05-23  5:30 ` pault at gcc dot gnu.org
2024-06-04 21:51 ` pault at gcc dot gnu.org
2024-06-20  7:01 ` cvs-commit 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-59104-4-GQbL0h8zMg@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: link
Be 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).