public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "paul.richard.thomas at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/62044] [4.8/4.9 Regression] ICE in USE statement with RENAME for extended derived type
Date: Mon, 26 Jan 2015 19:51:00 -0000	[thread overview]
Message-ID: <bug-62044-4-Rj9HCpIAAh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62044-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #12 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> ---
Dear All,

As I just said on #gfortran, the previous explanation is wrong. The
problem is that, for the mold= case with no default initializer, the
code->expr winds up being NULL. This fixes it and is being regtested:

Index: /svn/trunk/gcc/fortran/resolve.c
===================================================================
*** /svn/trunk/gcc/fortran/resolve.c    (revision 220097)
--- /svn/trunk/gcc/fortran/resolve.c    (working copy)
*************** resolve_allocate_expr (gfc_expr *e, gfc_
*** 6995,7003 ****
      {
        /* Default initialization via MOLD (non-polymorphic).  */
        gfc_expr *rhs = gfc_default_initializer (&code->expr3->ts);
!       gfc_resolve_expr (rhs);
!       gfc_free_expr (code->expr3);
!       code->expr3 = rhs;
      }

    if (e->ts.type == BT_CLASS && !unlimited && !UNLIMITED_POLY (code->expr3))
--- 6995,7006 ----
      {
        /* Default initialization via MOLD (non-polymorphic).  */
        gfc_expr *rhs = gfc_default_initializer (&code->expr3->ts);
!       if (rhs != NULL)
!     {
!       gfc_resolve_expr (rhs);
!       gfc_free_expr (code->expr3);
!       code->expr3 = rhs;
!     }
      }

    if (e->ts.type == BT_CLASS && !unlimited && !UNLIMITED_POLY (code->expr3))

If it regtests OK, I intend to commit right away as obvious. I guess
that for this completely stupid bug, I should backport to 4.9 at
least?

Cheers

Paul


On 26 January 2015 at 18:19, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> Dear Dominique,
>
> For some reason, the hash values are different in the vtable and the
> TYPE IS. I had always worried that that we would have different names
> giving the same hash sometime but not that the same name would give a
> different hash!
>
> The 'other brand'  gives the correct result.
>
> Thanks for the testcase!
>
> Paul
>
> On 26 January 2015 at 11:55, dominiq at lps dot ens.fr
> <gcc-bugzilla@gcc.gnu.org> wrote:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62044
>>
>> --- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
>>> The following, which works OK with another brand, selects the "wrong type"
>>> with trunk. 4.9 still segfaults. Without the use rename, 4.9 runs and gives
>>> the wrong result.
>>
>> The following test without module also selects the "wrong type" when compiled
>> with 4.8 up to 5.0
>>
>>   implicit none
>>   type, abstract :: GridImageSiloTemplate
>>   end type GridImageSiloTemplate
>>
>>   type, extends ( GridImageSiloTemplate ) :: &
>>     UnstructuredGridImageSiloForm
>>   end type UnstructuredGridImageSiloForm
>>
>>   call foo
>> contains
>>   subroutine foo
>>     class (GridImageSiloTemplate), allocatable :: a
>>     type (UnstructuredGridImageSiloForm) :: b
>>     allocate (a, mold = b)
>>     select type (a)
>>       type is (UnstructuredGridImageSiloForm)
>>         print *, "correct type selected"
>>       class default
>>         print *, "wrong type"
>>     end select
>>   end subroutine
>> end
>>
>> --
>> You are receiving this mail because:
>> You are on the CC list for the bug.
>
>
>
> --
> Outside of a dog, a book is a man's best friend. Inside of a dog it's
> too dark to read.
>
> Groucho Marx


  parent reply	other threads:[~2015-01-26 19:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-07  2:41 [Bug fortran/62044] New: " reubendb at gmail dot com
2014-08-11  8:32 ` [Bug fortran/62044] [4.8/4.9/4.10 Regression] " dominiq at lps dot ens.fr
2014-11-19 13:28 ` [Bug fortran/62044] [4.8/4.9/5 " rguenth at gcc dot gnu.org
2014-11-24 13:05 ` rguenth at gcc dot gnu.org
2014-12-19 13:42 ` jakub at gcc dot gnu.org
2015-01-14  8:31 ` janus at gcc dot gnu.org
2015-01-25 20:39 ` mikael at gcc dot gnu.org
2015-01-25 21:00 ` [Bug fortran/62044] [4.8/4.9 " mikael at gcc dot gnu.org
2015-01-26  6:40 ` paul.richard.thomas at gmail dot com
2015-01-26 11:55 ` dominiq at lps dot ens.fr
2015-01-26 13:06 ` mikael at gcc dot gnu.org
2015-01-26 13:11 ` mikael at gcc dot gnu.org
2015-01-26 18:12 ` paul.richard.thomas at gmail dot com
2015-01-26 18:20 ` paul.richard.thomas at gmail dot com
2015-01-26 19:51 ` paul.richard.thomas at gmail dot com [this message]
2015-01-26 20:13 ` damian at sourceryinstitute dot org
2015-01-26 20:20 ` damian at sourceryinstitute dot org
2015-01-26 21:59 ` pault at gcc dot gnu.org
2015-01-27 20:55 ` pault at gcc dot gnu.org
2015-01-27 21:04 ` pault 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-62044-4-Rj9HCpIAAh@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).