public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60357] [F08] structure constructor with unspecified values for allocatable components
Date: Sun, 21 Dec 2014 14:14:00 -0000	[thread overview]
Message-ID: <bug-60357-4-gNqzRcJcPd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60357-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The patch in comment 2 needs to be update to

--- ../_clean/gcc/fortran/primary.c    2014-12-16 22:27:14.000000000 +0100
+++ gcc/fortran/primary.c    2014-12-21 14:50:53.000000000 +0100
@@ -2367,6 +2367,13 @@ build_actual_constructor (gfc_structure_
         return false;
           value = gfc_copy_expr (comp->initializer);
         }
+      else if (comp->attr.allocatable)
+        {
+          if (!gfc_notify_std (GFC_STD_F2008, "No initializer for "
+          "allocatable component '%s' given in the structure "
+          "constructor at %C", comp->name))
+        return false;
+        }
       else if (!comp->attr.deferred_parameter)
         {
           gfc_error ("No initializer for component %qs given in the"

Note that while

    program testerprog
    use testmod
    Type(A) :: Me
    allocate(Me%y)
    Me = A(X=1, y=2)
    print *, Me%y

    end program

gives

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

    program testerprog
    use testmod
    Type(A) :: Me
    Me = A(X=1, y=2)
    print *, Me%x, Me%y

    end program

gives

           1           2

i.e., 'allocate(Me%y)' conflicts with Me = A(X=1, y=2). May be this expected.


  parent reply	other threads:[~2014-12-21 14:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 14:56 [Bug fortran/60357] New: " antony at cosmologist dot info
2014-02-27 22:19 ` [Bug fortran/60357] [F08] " janus at gcc dot gnu.org
2014-02-28 17:35 ` janus at gcc dot gnu.org
2014-08-12 15:15 ` dominiq at lps dot ens.fr
2014-12-21 14:14 ` dominiq at lps dot ens.fr [this message]
2014-12-23 23:46 ` janus at gcc dot gnu.org
2014-12-29 10:46 ` janus at gcc dot gnu.org
2014-12-29 10:55 ` janus at gcc dot gnu.org
2014-12-29 14:59 ` vehre at gmx dot de
2014-12-29 16:42 ` janus at gcc dot gnu.org
2014-12-29 17:37 ` vehre at gmx dot de
2014-12-29 17:37 ` vehre at gmx dot de
2015-01-17 18:09 ` pault at gcc dot gnu.org
2015-01-26 10:57 ` vehre 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-60357-4-gNqzRcJcPd@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).