public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/104922] New: bogus -Wformat-overflow=2 due to missing range for related variables
@ 2022-03-14 20:24 msebor at gcc dot gnu.org
2022-03-14 20:32 ` [Bug tree-optimization/104922] " msebor at gcc dot gnu.org
2022-03-14 20:35 ` msebor at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-03-14 20:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104922
Bug ID: 104922
Summary: bogus -Wformat-overflow=2 due to missing range for
related variables
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: diagnostic, lto
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
CC: amacleod at redhat dot com, marxin at gcc dot gnu.org,
msebor at gcc dot gnu.org, unassigned at gcc dot gnu.org
Depends on: 104746
Target Milestone: ---
+++ This bug was initially created as a clone of Bug #104746 +++
As mentioned in bug 104746 comment 5, the following test case triggers
-Wformat-overflow (level 2) due to the constraint on i and j not being fully
exposed to the warning (each directive on its own can produce at most two
bytes/digits, but when one does produce two digits the other must produce
exactly one, so the output must fit in four bytes). The same limitation
affects string directives with strings of bounded lengths.
As Andrew explains in bug 104746 comment 13, this can be improved in Ranger,
and should be made use of to avoid the warning.
char a[4];
void f (int i, int j)
{
if (i < 0 || j < 0 || i + j > 19)
return;
__builtin_sprintf (a, "%u%u", i, j);
}
a.c: In function ‘f’:
a.c:8:26: warning: ‘%u’ directive writing between 1 and 10 bytes into a region
of size 4 [-Wformat-overflow=]
8 | __builtin_sprintf (a, "%u%u", i, j);
| ^~
a.c:8:25: note: using the range [0, 4294967295] for directive argument
8 | __builtin_sprintf (a, "%u%u", i, j);
| ^~~~~~
a.c:8:25: note: using the range [0, 4294967295] for directive argument
a.c:8:3: note: ‘__builtin_sprintf’ output between 3 and 21 bytes into a
destination of size 4
8 | __builtin_sprintf (a, "%u%u", i, j);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104746
[Bug 104746] False positive for -Wformat-overflow=2 since
r12-7033-g3c9f762ad02f398c
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/104922] bogus -Wformat-overflow=2 due to missing range for related variables
2022-03-14 20:24 [Bug tree-optimization/104922] New: bogus -Wformat-overflow=2 due to missing range for related variables msebor at gcc dot gnu.org
@ 2022-03-14 20:32 ` msebor at gcc dot gnu.org
2022-03-14 20:35 ` msebor at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-03-14 20:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104922
Bug 104922 depends on bug 104746, which changed state.
Bug 104746 Summary: False positive for -Wformat-overflow=2 since r12-7033-g3c9f762ad02f398c
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104746
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |INVALID
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/104922] bogus -Wformat-overflow=2 due to missing range for related variables
2022-03-14 20:24 [Bug tree-optimization/104922] New: bogus -Wformat-overflow=2 due to missing range for related variables msebor at gcc dot gnu.org
2022-03-14 20:32 ` [Bug tree-optimization/104922] " msebor at gcc dot gnu.org
@ 2022-03-14 20:35 ` msebor at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-03-14 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104922
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|lto |missed-optimization
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-03-14
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed per bug 104746 comment 13.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-14 20:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 20:24 [Bug tree-optimization/104922] New: bogus -Wformat-overflow=2 due to missing range for related variables msebor at gcc dot gnu.org
2022-03-14 20:32 ` [Bug tree-optimization/104922] " msebor at gcc dot gnu.org
2022-03-14 20:35 ` 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).