Bug 72789 - add -Wunused-private-field
Summary: add -Wunused-private-field
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: diagnostic, patch
: 87409 (view as bug list)
Depends on:
Blocks: new-warning, new_warning Wunused
  Show dependency treegraph
 
Reported: 2016-08-03 13:13 UTC by Tom Tromey
Modified: 2026-03-25 21:14 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-08-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2016-08-03 13:13:43 UTC
I found out recently that clang has a '-Wunused-private-field'
warning.  E.g., I got:

https://github.com/mozilla/rr/pull/1757#issuecomment-237031428

I think it would be good to add this to gcc.
Comment 1 Eric Gallager 2017-08-22 15:12:37 UTC
Confirming as an enhancement.
Comment 2 Eric Gallager 2018-09-30 01:07:12 UTC
*** Bug 87409 has been marked as a duplicate of this bug. ***
Comment 3 Jean-Christian CÎRSTEA 2026-03-23 08:06:20 UTC
Working on a patch adding the option `-Wunused-private-field`.
Comment 4 Jean-Christian CÎRSTEA 2026-03-23 11:28:47 UTC
I have implemented `-Wunused-private-field`. However, it looks like g++ doesn't currently track whether a field is used or not, meaning that the option is useless. Am I missing something?
Comment 5 Jean-Christian CÎRSTEA 2026-03-24 07:41:12 UTC
A [patch](https://gcc.gnu.org/pipermail/gcc-patches/2026-March/711320.html) has been sent.