[Bug c/97687] New: -Wfatal-errors prints some notes but not others

nick at ludocode dot com gcc-bugzilla@gcc.gnu.org
Tue Nov 3 04:01:40 GMT 2020


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

            Bug ID: 97687
           Summary: -Wfatal-errors prints some notes but not others
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nick at ludocode dot com
  Target Milestone: ---

In file a.c:

    #define FOO foo
    typedef int FOO;
    typedef short FOO;


gcc a.c

    a.c:1:13: error: conflicting types for ‘foo’
        1 | #define FOO foo
        |             ^~~
    a.c:3:15: note: in expansion of macro ‘FOO’
        3 | typedef short FOO;
        |               ^~~
    a.c:1:13: note: previous declaration of ‘foo’ was here
        1 | #define FOO foo
        |             ^~~
    a.c:2:13: note: in expansion of macro ‘FOO’
        2 | typedef int FOO;
        |             ^~~


gcc -Wfatal-errors a.c

    a.c:1:13: error: conflicting types for ‘foo’
        1 | #define FOO foo
        |             ^~~
    a.c:3:15: note: in expansion of macro ‘FOO’
        3 | typedef short FOO;
        |               ^~~
    compilation terminated due to -Wfatal-errors.


-Wfatal-errors is printing some notes but not others. It would be much more
useful (to me) if it printed all of them, although in bugs #33952 and #37773
you claim that -Wfatal-errors is not for users, so I'm not really sure what you
want it to do here.

For what it's worth -fmax-errors=1 does the right thing and prints all three
notes, which I assume is what you want me to use. Unfortunately -fmax-errors=1
isn't supported by Clang so this makes my build system more complicated. Clang
supports -Wfatal-errors and prints all three notes.


$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)


More information about the Gcc-bugs mailing list