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/114827] Valgrind reports errors with class(*) assignment
Date: Wed, 24 Apr 2024 19:47:53 +0000	[thread overview]
Message-ID: <bug-114827-4-Q976cI7EF6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114827-4@http.gcc.gnu.org/bugzilla/>

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-04-24
           Keywords|                            |wrong-code

--- Comment #5 from anlauf at gcc dot gnu.org ---
Confirmed.

Two data points which give a hint what might be wrong:

1) the valgrind error count at runtime depends on the string length passed
   to foo.  I get no errors for a string of length 1.

2) the dump-tree of subroutine foo looks suspicious:

    if (b->_data == 0B)
      {
        b->_data = __builtin_malloc (MAX_EXPR <(unsigned long)
rhs.1._vptr->_size, 1>);

It looks like _size comes from:

  static struct __vtype_CHARACTER_1_ __vtab_CHARACTER_1_ = {._hash=85893463,
._size=1, ._extends=0B, ._def_init=0B, ._copy=__copy_character_1, ._final=0B};

and is always 1.  On the other hand, subroutine run sets:

        class.2._vptr = (struct __vtype__STAR * {ref-all})
&__vtab_CHARACTER_1_;
        class.2._data = (void *) &"fubarfubarfubarfubarfubarfu"[1]{lb: 1 sz:
1};
        class.2._len = 27;

but _len is used in foo for the _copy, but not for the allocation.

Thus the size allocated needs to be fixed.

Changing the character argument to use kind=4, I see that _size seems to
represent the element size.

The allocation size thus should be changed to (_size * _len).

Need to find the place where this happens...  Anyone?

  parent reply	other threads:[~2024-04-24 19:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-23 17:22 [Bug fortran/114827] New: " neil.n.carlson at gmail dot com
2024-04-23 17:24 ` [Bug fortran/114827] " neil.n.carlson at gmail dot com
2024-04-24  3:16 ` jvdelisle at gcc dot gnu.org
2024-04-24 13:19 ` neil.n.carlson at gmail dot com
2024-04-24 15:07 ` neil.n.carlson at gmail dot com
2024-04-24 19:47 ` anlauf at gcc dot gnu.org [this message]
2024-04-25 18:43 ` neil.n.carlson at gmail dot com
2024-04-26 19:33 ` anlauf at gcc dot gnu.org
2024-04-27 19:44 ` anlauf at gcc dot gnu.org
2024-04-28 20:37 ` anlauf at gcc dot gnu.org
2024-04-28 22:37 ` neil.n.carlson at gmail dot com
2024-04-29 18:39 ` anlauf at gcc dot gnu.org
2024-05-05 18:35 ` cvs-commit at gcc dot gnu.org
2024-05-09 18:30 ` cvs-commit 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-114827-4-Q976cI7EF6@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).