Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 15749
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: Tuomo Tikkanen <Tuomo.Tikkanen@nokia.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
main.E.bz2 gcc -E -pedantic-errors main.c > main.E application/octet-stream 2004-05-31 16:55 5.14 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

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

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2004-05-31 14:16
My collegue just today noticed that gcc version 3.4.0 behaves a bid odd on
Linux
when --pedantic-errors is used as compilation option to C-compiler (gcc):

<helix:/tmp> cat main.c 
#include <stdio.h>
#include <stdlib.h>
int main(void){printf("Hello world\n"); exit(EXIT_SUCCESS);}

<helix:/tmp> gcc --version
gcc (GCC) 3.4.0
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

<helix:/tmp> gcc --pedantic main.c 
<helix:/tmp> gcc --pedantic-errors main.c
In file included from /usr/include/libio.h:32,
                 from /usr/include/stdio.h:65,
                 from main.c:1:
/usr/include/_G_config.h:50: error: invalid use of structure with flexible
array
member
<helix:/tmp> 

If g++ is used instead of gcc:

<helix:/tmp> g++ --version
g++ (GCC) 3.4.0
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

<helix:/tmp> g++ --pedantic main.c
<helix:/tmp> g++ --pedantic-errors main.c
<helix:/tmp> 

This problem does not happen on Solaris/HPUX version nor does it happen when
older version (tested with 3.3.3 and 2.95.3) of gcc is used.

------- Comment #1 From Andrew Pinski 2004-05-31 16:22 -------
Can you provide the preprocessed source?
Also it looks like -pedantic-errors is enabling -Wsystem-headers which could be right or could be 
wrong but then this should be fixed in glibc anyways, they should be using __extension__.

------- Comment #2 From Joseph S. Myers 2004-05-31 16:36 -------
Subject: Re:  --pedantic-errors behaves differently from --pedantic
 with C-compiler on Linux

On Mon, 31 May 2004, pinskia at gcc dot gnu dot org wrote:

> Can you provide the preprocessed source?
> Also it looks like -pedantic-errors is enabling -Wsystem-headers which could be right or could be 
> wrong but then this should be fixed in glibc anyways, they should be using __extension__.

I'm testing a patch.  From the introductory text for this patch:

    The reason this didn't happen
    before 3.4 (although the detection of these misuses went into 3.3) is
    that pedwarn_with_decl didn't give any diagnostics in system headers
    at all, whereas with -pedantic-errors pedwarns in system headers cause
    errors unless there's a separate in_system_header check.  We may wish
    to revisit this and cause pedwarn() not to give diagnostics in system
    headers at all unless -Wsystem-headers (and also to revisit the
    various local in_system_header checks on warnings or, after such a
    change, pedwarns, that may predate -Wsystem-headers and the general
    disabling of warnings in system headers by default), but the safe fix
    for 3.4 branch is clearly that below which adds local tests of
    in_system_header to the pedwarns-if-pedantic for flexible array member
    misuse.

The disabling of warnings in system headers is intended to reduce the
extent to which existing headers need fixing with fixincludes.  It also
means __extension__ is mainly needed by such headers only in macros.


------- Comment #3 From Tuomo Tikkanen 2004-05-31 16:45 -------
*** Bug 15752 has been marked as a duplicate of this bug. ***

------- Comment #4 From Tuomo Tikkanen 2004-05-31 16:55 -------
Created an attachment (id=6438) [edit]
gcc -E -pedantic-errors main.c > main.E

Although there already seems to be quite clear understanding (and even patch?)
to this I still provide this bziped -E output if needed for reference.

------- Comment #5 From CVS Commits 2004-05-31 22:06 -------
Subject: Bug 15749

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2004-05-31 22:06:34

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr15749-1.c pr15749-1.h 

Log message:
	PR c/15749
	* c-decl.c (grokdeclarator, finish_struct): Don't pedwarn for
	misuses of structures with flexible array members if
	in_system_header.
	
	testsuite:
	* gcc.dg/pr15749-1.c, gcc.dg/pr15749-1.h: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.3808&r2=2.3809
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.503&r2=1.504
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3798&r2=1.3799
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr15749-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr15749-1.h.diff?cvsroot=gcc&r1=NONE&r2=1.1


------- Comment #6 From CVS Commits 2004-05-31 22:12 -------
Subject: Bug 15749

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jsm28@gcc.gnu.org	2004-05-31 22:12:01

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr15749-1.c pr15749-1.h 

Log message:
	PR c/15749
	* c-decl.c (grokdeclarator, finish_struct): Don't pedwarn for
	misuses of structures with flexible array members if
	in_system_header.
	
	testsuite:
	* gcc.dg/pr15749-1.c, gcc.dg/pr15749-1.h: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.458&r2=2.2326.2.459
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.470.4.13&r2=1.470.4.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.189&r2=1.3389.2.190
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr15749-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr15749-1.h.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1


------- Comment #7 From Andrew Pinski 2004-05-31 22:23 -------
Fixed.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug