public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/100876] -Wmismatched-new-delete should understand placement new when it's not inlined Date: Wed, 02 Jun 2021 18:16:40 +0000 [thread overview] Message-ID: <bug-100876-4-6oKsXBfHvj@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100876-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100876 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |100406 Known to fail| |11.1.0 Summary|-Wmismatched-new-delete |-Wmismatched-new-delete |should either look through |should understand placement |or ignore placement new |new when it's not inlined CC| |msebor at gcc dot gnu.org Component|c++ |middle-end --- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> --- [Please include all the information we ask for in the bug report, including the command line options and the full test cases: https://gcc.gnu.org/bugs/#need] The test case behaves as expected when the placement new is inlined, either with optimization or when the operator is declared with attribute always_inline: inline __attribute__ ((__always_inline__)) void* operator new (__SIZE_TYPE__, void*); The problem is a general one, not specific to -Wmismatched-new-delete: GCC understands the semantics of built-in functions, including whether they return one of their arguments, but not user-defined ones. Even though it's special, GCC treats placement new as an ordinary user-defined function. Because nothing indicates the operator returns its pointer argument, no logic in GCC can determine that unless the operator is inlined. The fix is to either hardcode into GCC the knowledge of placement new, or provide an attribute for users (and the standard library) to indicate that a function returns one of its argument. The former might be suitable for GCC 11 as a bug fix for this warning, the latter is something I'd like to do in GCC 12 regardless. Let me work on the former and plan on looking into the latter in the future. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100406 [Bug 100406] bogus/missing -Wmismatched-new-delete
next prev parent reply other threads:[~2021-06-02 18:16 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-02 13:46 [Bug c++/100876] New: -Wmismatched-new-delete should either look through or ignore placement new redbeard0531 at gmail dot com 2021-06-02 15:19 ` [Bug c++/100876] " redi at gcc dot gnu.org 2021-06-02 18:16 ` msebor at gcc dot gnu.org [this message] 2021-06-02 18:16 ` [Bug middle-end/100876] -Wmismatched-new-delete should understand placement new when it's not inlined msebor at gcc dot gnu.org 2021-06-02 21:42 ` msebor at gcc dot gnu.org 2021-06-14 22:51 ` cvs-commit at gcc dot gnu.org 2021-06-14 22:55 ` [Bug middle-end/100876] [11 Regression] " msebor at gcc dot gnu.org 2021-06-15 18:47 ` cvs-commit at gcc dot gnu.org 2021-06-17 20:08 ` cvs-commit at gcc dot gnu.org 2021-06-17 20:08 ` cvs-commit at gcc dot gnu.org 2021-06-17 20:11 ` msebor 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-100876-4-6oKsXBfHvj@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).