First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 18799
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Markus F.X.J. Oberhumer <markus@oberhumer.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 18799 depends on: Show dependency tree
Show dependency graph
Bug 18799 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2005-03-27 16:52 Opened: 2004-12-02 21:21
This code used to give a warning on gcc 3.2 and gcc 3.3, gcc 3.4 does not warn
at all, and current mainline 4.0 makes this an error.

What do the C89 and C99 standards actually say here ?

+ cat x.c
extern int x[];
static int x[2];
int *foo(void) { return x; }

+ gcc-3.2 -std=c89 -Wall -W -pedantic -c x.c
x.c:2: warning: static declaration for `x' follows non-static

+ gcc-3.3 -std=c89 -Wall -W -pedantic -c x.c
x.c:2: warning: static declaration for `x' follows non-static

+ gcc-3.4 -std=c89 -Wall -W -pedantic -c x.c

+ gcc-4.0 -std=c89 -Wall -W -pedantic -c x.c
x.c:2: error: static declaration of 'x' follows non-static declaration
x.c:1: error: previous declaration of 'x' was here

+ gcc-3.2 -std=c99 -Wall -W -pedantic -c x.c
x.c:2: warning: static declaration for `x' follows non-static

+ gcc-3.3 -std=c99 -Wall -W -pedantic -c x.c
x.c:2: warning: static declaration for `x' follows non-static

+ gcc-3.4 -std=c99 -Wall -W -pedantic -c x.c

+ gcc-4.0 -std=c99 -Wall -W -pedantic -c x.c
x.c:2: error: static declaration of 'x' follows non-static declaration
x.c:1: error: previous declaration of 'x' was here

------- Comment #1 From Andrew Pinski 2004-12-02 21:24 -------
The C standard says this is invalid code which is why 4.0.0 errors out.

------- Comment #2 From Markus F.X.J. Oberhumer 2004-12-02 23:12 -------
I'm reopening this against gcc-3.4.3 then, as the warning has vanished - a
possible regression against 3.2 and 3.3.

Note that gcc-3.4.3/gcc/c-decl.c talks about -Wtraditional, but even that
doesn't make the warning appear.

Please feel free to close this bug again if you disagree.


> gcc-3.3 -c -Wall -W -Wtraditional -pedantic x.c
x.c:2: warning: static declaration for `x' follows non-static
x.c: In function `foo':
x.c:3: warning: traditional C rejects ISO C style function definitions

> gcc-3.4.3 -c -Wall -W -Wtraditional -pedantic x.c
x.c: In function `foo':
x.c:3: warning: traditional C rejects ISO C style function definitions

------- Comment #3 From Falk Hueffner 2004-12-03 09:13 -------
Confirmed. I think we should even warn about this unconditionally and not
only with -pedantic.

------- Comment #4 From Joseph S. Myers 2005-04-30 00:04 -------
Fixed in 4.0.0.  c-decl.c in 3.4 was part way through a rewrite and
that intermediate version is fairly buggy and fragile, so backporting
fixes to that version seems inadvisable.

First Last Prev Next    No search results available      Search page      Enter new bug