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

--- Comment #7 from Harald van Dijk <harald at gigawatt dot nl> ---
(In reply to Albert Astals Cid from comment #5)
> (In reply to Harald van Dijk from comment #3)
> > If the header files cannot be modified, the -isystem command-line option
> > also causes included files to be treated as system headers where warnings
> > are suppressed.
> 
> The thing is, this isn't happening. If you compile the attached
> main-glib.cpp with
> 
> g++ -c -Wzero-as-null-pointer-constant main.cpp -isystem
> /usr/include/glib-2.0/ -isystem /usr/lib/glib-2.0/include

Huh, indeed. It works with the Ubuntu-provided GCC 8.3.0. It does not work with
the Ubuntu-provided GCC 9.1.0.

$ g++-8 -v
Using built-in specs.
COLLECT_GCC=g++-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.3.0-6ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-8
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1) 
$ g++-9 -v
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
9.1.0-2ubuntu2~19.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-9
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 9.1.0 (Ubuntu 9.1.0-2ubuntu2~19.04) 
$ g++-8 -c -Wzero-as-null-pointer-constant main.cpp -isystem
/usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include
$ g++-9 -c -Wzero-as-null-pointer-constant main.cpp -isystem
/usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include
main.cpp: In function ‘GType poppler_annot_get_type()’:
main.cpp:16:1: warning: zero as null pointer constant
[-Wzero-as-null-pointer-constant]
   16 | G_DEFINE_TYPE (PopplerAnnot, poppler_annot, G_TYPE_OBJECT)
      | ^~~~~~~~~~~~~

With GCC 9 without -isystem, it still shows the warning as coming from the
header ("/usr/include/glib-2.0/glib/gthread.h:250:42: warning: zero as null
pointer constant"), but when -isystem is used like that, the warning location
is moved to main.cpp, so no longer suppressed.

I do not know at this moment whether this is an intentional change in GCC 9.

Reply via email to