public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union Date: Mon, 11 Apr 2022 12:38:34 +0000 [thread overview] Message-ID: <bug-100370-4-Ubl5dsXeHy@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-100370-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>: https://gcc.gnu.org/g:790b02af6a1fcfa07dba6129909b3578a55a51fa commit r12-8079-g790b02af6a1fcfa07dba6129909b3578a55a51fa Author: Jason Merrill <jason@redhat.com> Date: Tue Apr 5 22:29:06 2022 -0400 c++: -Wplacement-new and anon union member [PR100370] This bug was an object/value confusion; we are interested in the size of *b.ip, but instead the code was calculating the size of b.ip itself. This seems to be because compute_objsize will compute the size of whatever object it can find in the argument: if you pass it a VAR_DECL, it gives you the size of that variable. If you pass it an ADDR_EXPR of a VAR_DECL, it again gives you the size of the variable. The way you can tell the difference is by looking at the deref member of access_ref: if it's -1, the argument is a pointer to the object. Since that's what we're interested in, we should check for that, like check_dangling_stores does. This regressed some tests because compute_objsize_r was wrongly zeroing deref in the POINTER_PLUS_EXPR handling; adding an offset to a pointer doesn't change whether the pointer is itself a variable or a pointer to one. In fact, handling POINTER_PLUS_EXPR only really makes sense for deref == -1, where we're adjusting a pointer to the variable. PR c++/100370 gcc/cp/ChangeLog: * init.cc (warn_placement_new_too_small): Check deref. gcc/ChangeLog: * pointer-query.cc (compute_objsize_r) [POINTER_PLUS_EXPR]: Require deref == -1. gcc/testsuite/ChangeLog: * g++.dg/warn/Wplacement-new-size-11.C: New test.
next prev parent reply other threads:[~2022-04-11 12:38 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu 2021-05-03 7:57 ` [Bug c++/100370] [11/12 Regression] " rguenth at gcc dot gnu.org 2021-05-03 16:48 ` msebor at gcc dot gnu.org 2021-07-28 7:06 ` [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union rguenth at gcc dot gnu.org 2022-01-20 13:57 ` rguenth at gcc dot gnu.org 2022-04-06 12:14 ` jason at gcc dot gnu.org 2022-04-07 1:29 ` jason at gcc dot gnu.org 2022-04-11 12:38 ` cvs-commit at gcc dot gnu.org [this message] 2022-04-21 7:49 ` [Bug c++/100370] [11 " rguenth at gcc dot gnu.org 2023-05-29 10:04 ` jakub 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-100370-4-Ubl5dsXeHy@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).