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/100551] [11/12 Regression] Passing return value of intrinsic to class(*) dummy argument can cause segfaults
Date: Wed, 12 May 2021 20:22:50 +0000	[thread overview]
Message-ID: <bug-100551-4-HJMVeRZK5D@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100551-4@http.gcc.gnu.org/bugzilla/>

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to Martin Liška from comment #1)
> Started with r11-6928-g4225af228b5d52e8.

The partial revert:

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index cce18d094a6..91efb67ac87 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5826,7 +5826,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                                     &derived_array);
        }
       else if (UNLIMITED_POLY (fsym) && e->ts.type != BT_CLASS
-              && gfc_expr_attr (e).flavor != FL_PROCEDURE)
+//            && gfc_expr_attr (e).flavor != FL_PROCEDURE)
+              )
        {
          /* The intrinsic type needs to be converted to a temporary
             CLASS object for the unlimited polymorphic formal.  */

fixes this issue but breaks testcase proc_ptr_52.f90.

Further reduced testcase for this PR:

program p
  implicit none
  integer :: result
  result = 1
! result = test (    (result)) ! works
  result = test (int (result)) ! fails
  write(*,*) result
contains
  integer function test(x)
    class(*), intent(in) :: x
    select type (x)
    type is (integer)
       test = x
    class default
       test = -1
    end select
  end function test
end program

  parent reply	other threads:[~2021-05-12 20:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 21:32 [Bug fortran/100551] New: " bugs at colin dot moe
2021-05-12  7:12 ` [Bug fortran/100551] " rguenth at gcc dot gnu.org
2021-05-12  9:41 ` marxin at gcc dot gnu.org
2021-05-12 20:22 ` anlauf at gcc dot gnu.org [this message]
2021-05-12 21:11 ` anlauf at gcc dot gnu.org
2021-05-13  7:41 ` anlauf at gcc dot gnu.org
2021-05-20 21:30 ` anlauf at gcc dot gnu.org
2021-05-23 18:52 ` cvs-commit at gcc dot gnu.org
2021-05-25 20:13 ` cvs-commit at gcc dot gnu.org
2021-05-25 20:16 ` anlauf at gcc dot gnu.org
2022-01-07 17:47 ` 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-100551-4-HJMVeRZK5D@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).