Bug 20562 - no unused warning for static const arrays
Summary: no unused warning for static const arrays
Status: RESOLVED DUPLICATE of bug 28901
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-03-19 23:13 UTC by Dirk Mueller
Modified: 2016-04-15 19:10 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.0
Known to fail: 4.0.0, 4.5.3, 4.8.3, 4.9.3, 5.3.0
Last reconfirmed: 2010-05-01 16:30:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Mueller 2005-03-19 23:13:07 UTC
given this code:  
  
=== Cut ===  
static const char * const tcvnlocales[] = { "vi", 0 };  
=== Cut ===  
  
There should be a "defined but not used" warning.
Comment 1 Andrew Pinski 2005-03-19 23:16:54 UTC
(In reply to comment #0)   
> There should be a "defined but not used" warning.

Why, this is a constant array so it is removed right?
Comment 2 Andrew Pinski 2005-03-19 23:19:41 UTC
(In reply to comment #1)
> (In reply to comment #0)   
> > There should be a "defined but not used" warning.
> 
> Why, this is a constant array so it is removed right?

Never mind, but I can tell you this was already fixed by the time 4.0.0 was branched.
Try with -Wunused.
Comment 3 Dirk Mueller 2005-03-19 23:32:26 UTC
whoops, wrong frontend. 
Comment 4 Wolfgang Bangerth 2005-03-20 22:46:49 UTC
IIRC, this was intentional because people had a habit of writing RCS 
"$ID:" strings at the top of files and wanted to find them again in 
the executable to identify which files exactly were linked together. 
 
You may find relevant discussions somewhere in the archives. 
 
W. 
Comment 5 Dirk Mueller 2005-03-20 23:22:53 UTC
this is where __attribute__((unused)) kicks in.. 
Comment 6 Andrew Pinski 2005-07-07 13:37:18 UTC
(In reply to comment #5)
> this is where __attribute__((unused)) kicks in.. 

But these shows up in system headers too.
Comment 7 Gabriel Dos Reis 2005-11-26 07:35:54 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)   
> > > There should be a "defined but not used" warning.
> > 
> > Why, this is a constant array so it is removed right?
> 
> Never mind, but I can tell you this was already fixed by the time 4.0.0 was branched.
> Try with -Wunused.

As of today GCC (mainline) produces NO diagnostics with -Wunused 
Comment 8 Gerald Pfeifer 2010-05-01 16:30:19 UTC
This is still the case with a current (2010-04-26) snapshot of GCC 4.6.0.
Comment 9 Martin Sebor 2016-04-15 19:10:16 UTC
This has been resolved in 6.0 via the -Wunused-const-variable option (see bug 28901).

*** This bug has been marked as a duplicate of bug 28901 ***