public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/115027] New: Missing warning: unused struct's with self-referential initialisers
@ 2024-05-10 12:27 dave at treblig dot org
2024-05-10 12:40 ` [Bug c/115027] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: dave at treblig dot org @ 2024-05-10 12:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115027
Bug ID: 115027
Summary: Missing warning: unused struct's with self-referential
initialisers
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dave at treblig dot org
Target Milestone: ---
It would be nice to generate a warning in the following case, which I tripped
over in the Linux kernel:
#include <stdio.h>
struct foo {
struct foo *a;
};
static struct foo f = { &f };
int main()
{
printf("Hello\n");
}
Here 'f' is unused outside of it's initialiser, pointing to itself.
So technically used, but practically not.
In the Linux kernel, this corresponds to it's LIST_HEAD :
(from include/linux/list.h)
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
and I've just gone through and posted patches to remove a handful of
LIST_HEADs, some of which had been unused for many years.
It would be nice if the compiler told people instead.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/115027] Missing warning: unused struct's with self-referential initialisers
2024-05-10 12:27 [Bug c/115027] New: Missing warning: unused struct's with self-referential initialisers dave at treblig dot org
@ 2024-05-10 12:40 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-10 12:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115027
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2024-05-10
CC| |hubicka at gcc dot gnu.org
Blocks| |89180
Keywords| |diagnostic
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think this is more an IPA issue but of course in theory the C fronted could
know it's parsing the initializer of 'f' when setting TREE_USED of 'f'.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89180
[Bug 89180] [meta-bug] bogus/missing -Wunused warnings
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-10 12:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 12:27 [Bug c/115027] New: Missing warning: unused struct's with self-referential initialisers dave at treblig dot org
2024-05-10 12:40 ` [Bug c/115027] " rguenth 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).