15749 – [3.4/4.0 Regression] --pedantic-errors behaves differently from --pedantic with C-compiler on Linux (original) (raw)
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 Drea 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 7 Drea Pinski 2004-05-31 22:23:24 UTC
Fixed.