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/110415] (Re)allocation on assignment to allocatable polymorphic variable from allocatable polymorphic function result Date: Mon, 20 Nov 2023 14:07:19 +0000 [thread overview] Message-ID: <bug-110415-4-1ZUs0HyKvR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-110415-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110415 Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> --- Andrew Jenner's submitted patch (gcc-patches@ only): https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636671.html and (fortran@ only): https://gcc.gnu.org/pipermail/fortran/2023-November/059928.html (Replies should got to both lists ...) * * * Technical it is a regression caused by https://gcc.gnu.org/r13-6747-gd7caf313525a46f200d7f5db1ba893f853774aee but before that commit there was no finalization. Comparing the versions: GCC 7+8: ICE in build_function_decl GCC 10+11+12: memory leak in 'func' GCC 13+mainline: segfault at runtime (at 'a = func()' in the main program). * * * I had analyzed the issue the elsewhere, let's copy it here for completeness and possibly to aid the patch review. (Note: The following was written before the patch was written and analyzed the current status.) ---<cut----- The 'func' has the prototype 'struct __class_MAIN___P_a func ()', i.e. returns the class-wrapper directly - and that part looks okay. However, the assignment somehow mixes everything up: D.4349 = a->_vptr; // save old value of vptr D.4328 = func (); // new value desc.0.data = (void * restrict) D.4328._data; // As scalar, there is not really a problem, but an // desc.0.dtype.elem_len = D.4328->_vptr->size; // is missing here. desc.0.span = (integer(kind=8)) desc.0.dtype.elem_len; if (__builtin_expect ((integer(kind=8)) (a->_data == 0B), 0, 42)) a->_data = (struct p *) __builtin_malloc (MAX_EXPR <(unsigned long) a->_vptr->_size, 1>); // WRONG: That should use D.4328->_vptr->size! else { if (a->_vptr != D.4349) { __builtin_realloc ((void *) a->_data, a->_vptr->_size); Likewise: a->_vptr should be D.4328->_vptr. Alternatively, a->_vptr had to be updated before the 'if' block.
next prev parent reply other threads:[~2023-11-20 14:07 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-26 15:47 [Bug fortran/110415] New: " everythingfunctional at protonmail dot com 2023-06-26 17:21 ` [Bug fortran/110415] " kargl at gcc dot gnu.org 2023-10-30 20:05 ` matthew.thompson at nasa dot gov 2023-11-20 14:07 ` burnus at gcc dot gnu.org [this message] 2023-11-28 15:28 ` cvs-commit at gcc dot gnu.org 2023-11-28 15:39 ` andrewjenner at gcc dot gnu.org 2024-05-21 19:16 ` anlauf at gcc dot gnu.org 2024-05-22 18:49 ` cvs-commit at gcc dot gnu.org 2024-05-22 18:52 ` anlauf 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-110415-4-1ZUs0HyKvR@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: linkBe 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).