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/98454] Apparent wrong initialization in function result
Date: Mon, 28 Dec 2020 09:47:56 +0000	[thread overview]
Message-ID: <bug-98454-4-mp7mbTtsdP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98454-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from anlauf at gcc dot gnu.org ---
(In reply to martin from comment #9)
> Problems with default initialisation of function result were fixed with
> PR45489. The relevant testcase added by this PR is initialization_27.f90
> which looks very similar to the reported problem (minus the non-initialised
> components).

Maybe they were addressed, but not fixed.

A further reduced testcase for the present problem:

program p
  implicit none
  type t
    integer :: unit = -1
  end type t
  type(t) :: x
  x = g()
  if (x% unit /= -1) stop 2
  x = f()
  if (x% unit /= -1) stop 3
contains
  function f()
    type(t) :: f
  end function f
  function g()
    type(t) :: g
    if (g% unit /= -1) stop 1
  end function g
end

The program fails with

STOP 3

Looking into the tree-dump shows that g() is fine, f() is not.

Thanks for the pointer to PR45489, which may provide a starting point.

  parent reply	other threads:[~2020-12-28  9:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-27 13:28 [Bug fortran/98454] New: " fmartinez at gmv dot com
2020-12-27 19:54 ` [Bug fortran/98454] " kargl at gcc dot gnu.org
2020-12-27 21:25 ` anlauf at gcc dot gnu.org
2020-12-27 21:44 ` anlauf at gcc dot gnu.org
2020-12-27 21:59 ` kargl at gcc dot gnu.org
2020-12-27 22:01 ` anlauf at gcc dot gnu.org
2020-12-27 22:15 ` ffadrique at gmail dot com
2020-12-27 22:18 ` ffadrique at gmail dot com
2020-12-27 23:07 ` sgk at troutmask dot apl.washington.edu
2020-12-28  8:46 ` mscfd at gmx dot net
2020-12-28  9:47 ` anlauf at gcc dot gnu.org [this message]
2020-12-28 15:19 ` anlauf 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-98454-4-mp7mbTtsdP@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).