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/52102] [OOP] Wrong result with ALLOCATE of CLASS components with array constructor SOURCE-expr
Date: Fri, 03 Feb 2012 13:38:00 -0000	[thread overview]
Message-ID: <bug-52102-4-z3GtAmolfi@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-52102-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52102

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-03 13:37:39 UTC ---
Related issue with MOLD=, here one gets with "x = 5" default initialization and

  allocate (two%a(8), mold=t(4))
  print '(*(i2))', two%a(:)%x
the result:
 0 0 0 0 0 0 0 5

That is: only the last element gets the value.

>From the dump:
   two.a._data.offset = -1;
...
     struct t t.2;
     t.2.x = 5;
     D.1886 = t.2;
     __vtab_MAIN___T._copy (&D.1886,
         &(*(struct t[0:] * restrict) two.a._data.data)[two.a._data.offset +
8]);

Note the constant offset of "8", which matches the ubound. Note further that
the _copy construct is *not* in a scalarizing loop but only called once for the
last element.


 * * *

The following looks odd:

gfc_trans_allocate (gfc_code * code)
{
...
      if (code->expr3 && !code->expr3->mold)
        {
...
              /* Do a polymorphic deep copy.  */
...
              actual->next->expr = gfc_copy_expr (al->expr);
              dataref = actual->next->expr->ref;
              if (dataref->u.c.component->as)

The latter makes no sense in this case as the base object is not the class
container. We need to access the last component ref on the ref list.


  parent reply	other threads:[~2012-02-03 13:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03  7:49 [Bug fortran/52102] New: [OOP] Wrong result with ALLOCATE w/ SOURCE= and nonpoly. array constructor source-expr burnus at gcc dot gnu.org
2012-02-03  8:22 ` [Bug fortran/52102] [OOP] Wrong result with ALLOCATE of CLASS components with array constructor SOURCE-expr burnus at gcc dot gnu.org
2012-02-03 13:22 ` burnus at gcc dot gnu.org
2012-02-03 13:38 ` burnus at gcc dot gnu.org [this message]
2012-02-05 19:56 ` pault at gcc dot gnu.org
2012-02-05 20:06 ` 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-52102-4-z3GtAmolfi@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).