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/48958] Add runtime diagnostics for SIZE intrinsic function
Date: Mon, 16 Nov 2020 22:31:12 +0000	[thread overview]
Message-ID: <bug-48958-4-oXl48BNTVN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48958-4@http.gcc.gnu.org/bugzilla/>

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5
             Status|SUSPENDED                   |NEW
                 CC|anlauf at gmx dot de               |
          Component|libfortran                  |fortran

--- Comment #7 from anlauf at gcc dot gnu.org ---
The question on what to do with runtime checks and possibly undefined pointers,
which has been repeated by Thomas on the ML, could be solved by initializing
the data component when -fcheck=pointer is specified.

A somewhat hackish solution which regtests cleanly:

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index b2c39aa32de..6e1f27ead45 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -10668,7 +10668,9 @@ gfc_trans_deferred_array (gfc_symbol * sym,
gfc_wrapped_block * block)
     }

   /* NULLIFY the data pointer, for non-saved allocatables.  */
-  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save &&
sym->attr.allocatable)
+  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save
+      && (sym->attr.allocatable
+         || (sym->attr.pointer && (gfc_option.rtcheck &
GFC_RTCHECK_POINTER))))
     {
       gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
       if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)

Still need to learn weather this is the right solution, but it does the job.

      parent reply	other threads:[~2020-11-16 22:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11  8:09 [Bug libfortran/48958] New: " thenlich at users dot sourceforge.net
2015-10-14 21:45 ` [Bug libfortran/48958] " anlauf at gmx dot de
2015-10-15  9:36 ` dominiq at lps dot ens.fr
2020-11-14 22:16 ` anlauf at gcc dot gnu.org
2020-11-16 21:01 ` cvs-commit at gcc dot gnu.org
2020-11-16 22:31 ` anlauf at gcc dot gnu.org [this message]

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-48958-4-oXl48BNTVN@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).