public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/96725] New: warn for uses of global nonconstant unterminated char arrays where strings are required
@ 2020-08-20 16:59 msebor at gcc dot gnu.org
2020-08-20 16:59 ` [Bug middle-end/96725] " msebor at gcc dot gnu.org
2021-01-21 22:46 ` msebor at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-08-20 16:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96725
Bug ID: 96725
Summary: warn for uses of global nonconstant unterminated char
arrays where strings are required
Product: gcc
Version: 11.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: ---
Although using a non-constant array initialized to all non-nul characters where
a nul-terminated string is expected doesn't necessarily imply the initializer
is what's used, it is an indication that it might be used, and so a warning
would be helpful, especially in code that doesn't make use of const.
$ cat z.c && gcc -O2 -S -Wall -Wrestrict -fdump-tree-strlen=/dev/stdout z.c
char a[4] = { 1, 2, 3, 4 };
int f (void) { return __builtin_strlen (a); } // warn here
;; Function f (f, funcdef_no=0, decl_uid=1932, cgraph_uid=1, symbol_order=1)
;; 1 loops found
;;
;; Loop 0
;; header 0, latch 1
;; depth 0, outer -1
;; nodes: 0 1 2
;; 2 succs { 1 }
f ()
{
long unsigned int _1;
int _3;
<bb 2> [local count: 1073741824]:
_1 = __builtin_strlen (&a);
_3 = (int) _1;
return _3;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/96725] warn for uses of global nonconstant unterminated char arrays where strings are required
2020-08-20 16:59 [Bug middle-end/96725] New: warn for uses of global nonconstant unterminated char arrays where strings are required msebor at gcc dot gnu.org
@ 2020-08-20 16:59 ` msebor at gcc dot gnu.org
2021-01-21 22:46 ` msebor at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2020-08-20 16:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96725
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Severity|normal |enhancement
Blocks| |88443
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/96725] warn for uses of global nonconstant unterminated char arrays where strings are required
2020-08-20 16:59 [Bug middle-end/96725] New: warn for uses of global nonconstant unterminated char arrays where strings are required msebor at gcc dot gnu.org
2020-08-20 16:59 ` [Bug middle-end/96725] " msebor at gcc dot gnu.org
@ 2021-01-21 22:46 ` msebor at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-01-21 22:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96725
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks|88443 |97048
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-01-21
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirming as a -Wstringop-overread enhancement.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
[Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97048
[Bug 97048] [meta-bug] bogus/missing -Wstringop-overread warnings
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-21 22:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 16:59 [Bug middle-end/96725] New: warn for uses of global nonconstant unterminated char arrays where strings are required msebor at gcc dot gnu.org
2020-08-20 16:59 ` [Bug middle-end/96725] " msebor at gcc dot gnu.org
2021-01-21 22:46 ` 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).