public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109123] Bogus warning: pointer used after 'realloc' -Wuse-after-free with -O2 Date: Tue, 14 Mar 2023 09:55:25 +0000 [thread overview] Message-ID: <bug-109123-4-HhJzOR97RH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-109123-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109123 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Last reconfirmed| |2023-03-14 --- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- size_t old_size = vector_objective_size(v); if (n > old_capacity) { v->_begin = realloc(v->_begin, sizeof(double) * n); v->_end = v->_begin + old_size; GCC has sunk part of the old_size computation (not the loads but the subtraction) to after the realloc but before the use of old_size. The diagnostic code doesn't deal with this code motion very well (read: it diagnoses it). We do have plenty of dups for this but the author of the diagnostic says diagnosing is done on purpose here. There's no way to fix this. It doesn't make sense to limit optimization for this academic "use-after-free", nor would it be an easy task because of the lack of explicit dependences in the IL. Confirmed (the diagnostic is happening).
next prev parent reply other threads:[~2023-03-14 9:55 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-14 9:41 [Bug c/109123] New: Bogus warning: pointer used after 'realloc' -Wuse-after-free manu at gcc dot gnu.org 2023-03-14 9:44 ` [Bug c/109123] Bogus warning: pointer used after 'realloc' -Wuse-after-free with -O2 manu at gcc dot gnu.org 2023-03-14 9:48 ` manu at gcc dot gnu.org 2023-03-14 9:55 ` rguenth at gcc dot gnu.org [this message] 2023-03-14 10:00 ` manu at gcc dot gnu.org 2023-03-14 10:03 ` manu at gcc dot gnu.org 2023-03-14 10:22 ` manu at gcc dot gnu.org 2023-03-14 12:17 ` rguenth at gcc dot gnu.org 2023-03-14 12:51 ` manu at gcc dot gnu.org 2023-03-15 8:16 ` rguenth at gcc dot gnu.org 2023-03-16 7:30 ` cvs-commit at gcc dot gnu.org 2023-03-16 7:31 ` [Bug c/109123] [12 Regression] " rguenth at gcc dot gnu.org 2023-05-08 12:26 ` [Bug tree-optimization/109123] " rguenth 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-109123-4-HhJzOR97RH@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).