public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/97084] Openmp + Allocatable String Crashes
Date: Wed, 07 Oct 2020 07:16:04 +0000	[thread overview]
Message-ID: <bug-97084-4-KtgdzS0CJ4@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97084-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Trying with:
  character(len=:), allocatable :: temp_string
  character(len=N) :: temp_string2
(using one or the other)

Both get set to 'shared' initially; in omp-low.c' scan_sharing_clauses:
        case OMP_CLAUSE_SHARED:
...
          by_ref = use_pointer_for_field (decl, NULL);

As "temp_string2" is a string/array, by_ref is true as:
  if (AGGREGATE_TYPE_P (TREE_TYPE (decl))
      || TYPE_ATOMIC (TREE_TYPE (decl)))
    return true;

By contrast, temp_string is a pointer to a string/array, has 'by_ref = false'
and, hence,
          /* We don't need to copy const scalar vars back.  */
          OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_FIRSTPRIVATE);

→ This statement is definitely wrong as it is not a scalar (in the OpenMP
sense) and it is also not 'const' and it should be addressable.

The question is why not any of the many items in the if condition following
line 1143's "by_ref =" is true.


Back to the ICE: Then, via lower_rec_input_clauses, gfc_omp_clause_copy_ctor is
called and we end up at:
  gfc_start_block (&block);
  gfc_init_block (&cond_block);
  gfc_add_modify (&cond_block, dest, src));

"lhs = rhs" is:
  temp_string = .omp_data_s.1.temp_string

where both lhs and rhs are pointers to an array; in the dump both types look
identical but are different pointer/array types. Thus, the following assert
fails in gfc_add_modify_loc:

  gcc_checking_assert (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)
                       || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));

  parent reply	other threads:[~2020-10-07  7:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 10:28 [Bug fortran/97084] New: " wddawson at ucdavis dot edu
2020-10-06 13:16 ` [Bug fortran/97084] " dominiq at lps dot ens.fr
2020-10-07  7:16 ` burnus at gcc dot gnu.org [this message]
2020-10-07  7:42 ` burnus 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-97084-4-KtgdzS0CJ4@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).