https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61412

            Bug ID: 61412
           Summary: Warnings incorrectly suppressed when compiling
                    previously preprocessed file
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt at godbolt dot org

Some warnings appear to be lost when compiling a previously-preprocessed source
file (e.g. as a result of using ccache, which caches the intermediate
preprocessed source). A minimal example (of a post-preprocessed file):

--begin example
# 88 "some/file.cpp" 3 4
struct Foo { int i, j; Foo() : j(1), i(0) {} };
--end example

compiled with: "g++ -c -Wall -Wextra -Werror -o /tmp/foo /tmp/pp.ii" there is
no warning or error about the reordered initializer.  However, removing the
first line (the # directive) to yield:

--begin example2
struct Foo { int i, j; Foo() : j(1), i(0) {} };
--end example2

gives the error, as expected:
/tmp/pp.ii: In constructor ‘Foo::Foo()’:
/tmp/pp.ii:2:21: error: ‘Foo::j’ will be initialized after [-Werror=reorder]
 struct Foo { int i, j; Foo() : j(1), i(0) {} };
                     ^
/tmp/pp.ii:2:18: error:   ‘int Foo::i’ [-Werror=reorder]
 struct Foo { int i, j; Foo() : j(1), i(0) {} };
                  ^
/tmp/pp.ii:2:24: error:   when initialized here [-Werror=reorder]
 struct Foo { int i, j; Foo() : j(1), i(0) {} };
                        ^

GCC version:
$ g++ -v
Using built-in specs.
COLLECT_GCC=/home/mgodbolt/.fighome/runtime/gcc/4.9.0-2/bin/g++
COLLECT_LTO_WRAPPER=/mnt/data/fighome/runtime/gcc/4.9.0-2/bin/../libexec/gcc/x86_64-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-4.9.0/configure --prefix
/data/teamcity/work/sud-chibld05-002-RHEL6/9d49ff0b2777552a/scratch/gcc/4.9.0/staging
--build=x86_64-linux-gnu --disable-multilibs --enable-clocale=gnu
--enable-languages=c,c++ --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix --host=x86_64-linux-gnu
--target=x86_64-linux-gnu --with-pkgversion=DRW-internal-build
--with-system-zlib --disable-werror
--with-libelf=/data/teamcity/work/sud-chibld05-002-RHEL6/9d49ff0b2777552a/scratch/gcc/4.9.0/build/libelf-0.8.13
Thread model: posix
gcc version 4.9.0 (DRW-internal-build) 

Running on Linux.  Does not happen with GCC 4.7.2.

Reply via email to