public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new
@ 2021-05-01 11:54 foldy at rmki dot kfki.hu
2021-05-03 7:57 ` [Bug c++/100370] [11/12 Regression] " rguenth at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: foldy at rmki dot kfki.hu @ 2021-05-01 11:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Bug ID: 100370
Summary: [11.1.0 regression] Incorrect warning for placement
new
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: foldy at rmki dot kfki.hu
Target Milestone: ---
With g++ 11.1.0:
tmp> cat test.cc
#include <new>
int main()
{
struct s1 { int iv[4]; };
struct s2 { union { char* cp; int* ip; }; };
s2 b;
b.ip=new int[8];
new (b.ip+4) s1;
}
tmp> g++ -c test.cc
test.cc: In function 'int main()':
test.cc:10:12: warning: placement new constructing an object of type
'main()::s1' and size '16' in a region of type 'main()::s2' and size '0'
[-Wplacement-new=]
10 | new (b.ip+4) s1;
| ~~~~^~
test.cc:8:6: note: at offset 16 from 'b' declared here
8 | s2 b;
| ^
g++ 10.2.1 is OK.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect warning for placement new
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 ` rguenth at gcc dot gnu.org
2021-05-03 16:48 ` msebor at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-03 7:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11.1.0 regression] |[11/12 Regression]
|Incorrect warning for |Incorrect warning for
|placement new |placement new
Target Milestone|--- |11.2
Version|unknown |11.1.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect warning for placement new
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
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-05-03 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |100399
Last reconfirmed| |2021-05-03
Known to fail| |11.1.0
Status|UNCONFIRMED |NEW
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. The false positive here is the result of trying to avoid other
false positives for unions and not considering that the pointer might point to
space that's larger than that. Like the false negative in pr100307 comment 2
(AKA pr100325), this would also be prevented by running -Wplacement-new later,
when the program is in SSA form, rather than from the front end.
if (code == COMPONENT_REF)
{
tree ref = TREE_OPERAND (ptr, 0);
if (TREE_CODE (TREE_TYPE (ref)) == UNION_TYPE)
/* In accesses through union types consider the entire unions
rather than just their members. */
ostype = 0;
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100399
[Bug 100399] bogus/missing -Wplacement-new
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union
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 ` rguenth at gcc dot gnu.org
2022-01-20 13:57 ` rguenth at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.2 |11.3
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-20 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-06 12:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=70834
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (4 preceding siblings ...)
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
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-04-07 1:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2022-April/592856.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11/12 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (5 preceding siblings ...)
2022-04-07 1:29 ` jason at gcc dot gnu.org
@ 2022-04-11 12:38 ` cvs-commit at gcc dot gnu.org
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
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-11 12:38 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (6 preceding siblings ...)
2022-04-11 12:38 ` cvs-commit at gcc dot gnu.org
@ 2022-04-21 7:49 ` rguenth at gcc dot gnu.org
2023-05-29 10:04 ` jakub at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-21 7:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.3 |11.4
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.3 is being released, retargeting bugs to GCC 11.4.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/100370] [11 Regression] Incorrect -Wplacement-new with union
2021-05-01 11:54 [Bug c++/100370] New: [11.1.0 regression] Incorrect warning for placement new foldy at rmki dot kfki.hu
` (7 preceding siblings ...)
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
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100370
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.4 |11.5
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-05-29 10:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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).