public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111398] New: GCC should warn if a struct with flexible array member is declared static or onstack
@ 2023-09-13 4:19 tg at mirbsd dot org
2023-09-13 7:44 ` [Bug c/111398] " rguenth at gcc dot gnu.org
2023-09-13 16:59 ` tg at mirbsd dot org
0 siblings, 2 replies; 3+ messages in thread
From: tg at mirbsd dot org @ 2023-09-13 4:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111398
Bug ID: 111398
Summary: GCC should warn if a struct with flexible array member
is declared static or onstack
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tg at mirbsd dot org
Target Milestone: ---
If I have (-std=c99 and up) a…
struct foo {
size_t len;
char buf[];
};
… then I would like to be warned (at least with -Wextra or something) if I do
either of…
static struct foo a; // this
struct foo b; // this
extern struct foo x; // and probably even this!
void bla(void) {
static struct foo c; // this
struct foo d; // and this
}
(Probably the same for GCC’s char buf[0]; extension.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/111398] GCC should warn if a struct with flexible array member is declared static or onstack
2023-09-13 4:19 [Bug c/111398] New: GCC should warn if a struct with flexible array member is declared static or onstack tg at mirbsd dot org
@ 2023-09-13 7:44 ` rguenth at gcc dot gnu.org
2023-09-13 16:59 ` tg at mirbsd dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-09-13 7:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111398
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Version|unknown |14.0
Severity|normal |enhancement
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The C standard explicitely makes these cases valid. I agree it's probably
unintended in most cases.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/111398] GCC should warn if a struct with flexible array member is declared static or onstack
2023-09-13 4:19 [Bug c/111398] New: GCC should warn if a struct with flexible array member is declared static or onstack tg at mirbsd dot org
2023-09-13 7:44 ` [Bug c/111398] " rguenth at gcc dot gnu.org
@ 2023-09-13 16:59 ` tg at mirbsd dot org
1 sibling, 0 replies; 3+ messages in thread
From: tg at mirbsd dot org @ 2023-09-13 16:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111398
--- Comment #2 from Thorsten Glaser <tg at mirbsd dot org> ---
Right, which is why I suggested a -Wextra level option to warn about these.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-13 16:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-13 4:19 [Bug c/111398] New: GCC should warn if a struct with flexible array member is declared static or onstack tg at mirbsd dot org
2023-09-13 7:44 ` [Bug c/111398] " rguenth at gcc dot gnu.org
2023-09-13 16:59 ` tg at mirbsd dot 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).