Bug 15749 - [3.4/4.0 Regression] --pedantic-errors behaves differently from --pedantic with C-compiler on Linux
Summary: [3.4/4.0 Regression] --pedantic-errors behaves differently from --pedantic wi...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 15752 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-05-31 14:16 UTC by Tuomo Tikkanen
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
gcc -E -pedantic-errors main.c > main.E (5.14 KB, application/octet-stream)
2004-05-31 16:55 UTC, Tuomo Tikkanen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tuomo Tikkanen 2004-05-31 14:16:23 UTC
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 Andrew Pinski 2004-05-31 16:22:53 UTC
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 Joseph S. Myers 2004-05-31 16:36:29 UTC
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 Tuomo Tikkanen 2004-05-31 16:45:15 UTC
*** Bug 15752 has been marked as a duplicate of this bug. ***
Comment 4 Tuomo Tikkanen 2004-05-31 16:55:09 UTC
Created attachment 6438 [details]
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 CVS Commits 2004-05-31 22:06:53 UTC
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 7 Andrew Pinski 2004-05-31 22:23:24 UTC
Fixed.