public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal
@ 2021-07-16 16:58 msebor at gcc dot gnu.org
2021-12-16 18:28 ` [Bug middle-end/101475] " msebor at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-07-16 16:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101475
Bug ID: 101475
Summary: missing -Wstringop-overflow storing a compound literal
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
Even with pr97027 resolved -Wstringop-overflow is not issued consistently (on
all targets) for buffer overflow when storing a larger compound literal into a
smaller buffer. The test case below is diagnosed by -Warray-bounds which is
only enabled with -Wall and at -O2, but not by -Wstringop-overflow (which is
enabled by default). Ideally the bug should be diagnosed even at -O0.
$ cat a.c && gcc -O2 -S -fdump-tree-strlen=/dev/stdout a.c
typedef struct A { char a[4]; } A;
extern char a[2];
void f (void)
{
*(A*)a = (A){ 1, 2, 3, 4 }; // missing warning
}
typedef struct B { int a[2]; } B;
void g (void)
{
*(B*)a = (B){ 1, 2 }; // missing warning
}
;; Function f (f, funcdef_no=0, decl_uid=3910, cgraph_uid=1, symbol_order=0)
;; 1 loops found
;;
;; Loop 0
;; header 0, latch 1
;; depth 0, outer -1
;; nodes: 0 1 2
;; 2 succs { 1 }
void f ()
{
<bb 2> [local count: 1073741824]:
MEM[(struct A *)&a].a[0] = 1;
MEM[(struct A *)&a].a[1] = 2;
MEM[(struct A *)&a].a[2] = 3;
MEM[(struct A *)&a].a[3] = 4;
return;
}
;; Function g (g, funcdef_no=1, decl_uid=3917, cgraph_uid=2, symbol_order=1)
;; 1 loops found
;;
;; Loop 0
;; header 0, latch 1
;; depth 0, outer -1
;; nodes: 0 1 2
;; 2 succs { 1 }
void g ()
{
<bb 2> [local count: 1073741824]:
MEM[(struct B *)&a].a[0] = 1;
MEM[(struct B *)&a].a[1] = 2;
return;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/101475] missing -Wstringop-overflow storing a compound literal
2021-07-16 16:58 [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal msebor at gcc dot gnu.org
@ 2021-12-16 18:28 ` msebor at gcc dot gnu.org
2021-12-16 19:57 ` msebor at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-16 18:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101475
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |crazylht at gmail dot com
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
*** Bug 102722 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/101475] missing -Wstringop-overflow storing a compound literal
2021-07-16 16:58 [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal msebor at gcc dot gnu.org
2021-12-16 18:28 ` [Bug middle-end/101475] " msebor at gcc dot gnu.org
@ 2021-12-16 19:57 ` msebor at gcc dot gnu.org
2022-01-14 18:14 ` cvs-commit at gcc dot gnu.org
2022-01-14 18:15 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-12-16 19:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101475
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2021-12-16
Ever confirmed|0 |1
Target Milestone|--- |12.0
Keywords| |patch
Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-December/587033.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/101475] missing -Wstringop-overflow storing a compound literal
2021-07-16 16:58 [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal msebor at gcc dot gnu.org
2021-12-16 18:28 ` [Bug middle-end/101475] " msebor at gcc dot gnu.org
2021-12-16 19:57 ` msebor at gcc dot gnu.org
@ 2022-01-14 18:14 ` cvs-commit at gcc dot gnu.org
2022-01-14 18:15 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-01-14 18:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101475
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:
https://gcc.gnu.org/g:72332337e3d8acbb21398b8d123f1bfe77a8327e
commit r12-6592-g72332337e3d8acbb21398b8d123f1bfe77a8327e
Author: Martin Sebor <msebor@redhat.com>
Date: Fri Jan 14 11:13:08 2022 -0700
Use enclosing object size if it's smaller than member [PR 101475].
Resolves:
PR middle-end/101475 - missing -Wstringop-overflow storing a compound
literal
gcc/ChangeLog:
PR middle-end/101475
* pointer-query.cc (handle_component_ref): Use the size of
the enclosing object if it's smaller than the member.
gcc/testsuite/ChangeLog:
PR middle-end/101475
* gcc.dg/Wstringop-overflow-15.c: Remove xfails.
* gcc.dg/Wstringop-overflow-68.c: Adjust, remove xfails.
* gcc.dg/Wstringop-overflow-88.c: New test.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/101475] missing -Wstringop-overflow storing a compound literal
2021-07-16 16:58 [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal msebor at gcc dot gnu.org
` (2 preceding siblings ...)
2022-01-14 18:14 ` cvs-commit at gcc dot gnu.org
@ 2022-01-14 18:15 ` msebor at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-01-14 18:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101475
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Fixed in r12-6592.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-14 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 16:58 [Bug middle-end/101475] New: missing -Wstringop-overflow storing a compound literal msebor at gcc dot gnu.org
2021-12-16 18:28 ` [Bug middle-end/101475] " msebor at gcc dot gnu.org
2021-12-16 19:57 ` msebor at gcc dot gnu.org
2022-01-14 18:14 ` cvs-commit at gcc dot gnu.org
2022-01-14 18:15 ` msebor 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).