public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/40661] New: Incorrect warning "defined but not used"
@ 2009-07-06 16:56 ahelm at gmx dot net
2009-07-06 16:59 ` [Bug c/40661] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: ahelm at gmx dot net @ 2009-07-06 16:56 UTC (permalink / raw)
To: gcc-bugs
=========== Begin complete code ===========
#include <stdio.h>
static int y = -1234;
int main(void)
{
extern int y;
printf("%d\n", y);
return 0;
}
=========== End complete code ===========
command line: gcc -W -Wall test.c
Output:
test.c:3: warning: 'y' defined but not used
As you can see "y" is defined (in line 3), then declared in line 7
and used in line 8. The program also executes correctly.
The use of an "extern" storage class specifier is a bit unusual
but perfectly legal (See ISO/IEC 9899:1999 chapter 6.2.2, paragraph 4).
If anything a warning about this slightly obscure construct might be in OK,
but not about an unused variable.
I would have liked to verify with a newer GCC version but haven't
got any available here, sorry.
--
Summary: Incorrect warning "defined but not used"
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ahelm at gmx dot net
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40661
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/40661] Incorrect warning "defined but not used"
2009-07-06 16:56 [Bug c/40661] New: Incorrect warning "defined but not used" ahelm at gmx dot net
@ 2009-07-06 16:59 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-07-06 16:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2009-07-06 16:59 -------
This was fixed in 4.0.0, the c-decl rewrite was not completed until 4.0.0
really.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40661
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-06 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-06 16:56 [Bug c/40661] New: Incorrect warning "defined but not used" ahelm at gmx dot net
2009-07-06 16:59 ` [Bug c/40661] " pinskia at gcc dot gnu 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).