public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stefan.bruens@rwth-aachen.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/103848] [11/12 Regression] std::deque<>::iterator operator- uses "0" for nullptr check, triggers "zero-as-null-pointer-constant" warning
Date: Wed, 05 Jan 2022 03:08:41 +0000	[thread overview]
Message-ID: <bug-103848-4-vU8HbGt058@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103848-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Stefan Brüns <stefan.bruens@rwth-aachen.de> ---
(In reply to Jonathan Wakely from comment #2)
> This is not a bug.
> 
> Firstly, there's no testcase provided (as https://gcc.gnu.org/bugs says is
> needed). Here's the missing testcase:
> 
> #include <deque>
> std::deque<int> d;
> auto n = d.begin() - d.begin();
> 
> Secondly, the command to reproduce the error is not provided, as the link
> also says is needed. This "error" only happens with
> -Werror=zero-as-null-pointer-constant -Wsystem-headers, so don't do that.
> This is not even a warning unless you explicitly ask for it (it's not in
> -Wall or -Wextra) and if you choose to make it an error, that's your fault.
> 
> We can't nullptr because the code needs to compile as C++98. We could use
> NULL or __null, or Jakub suggested just _Map_pointer. I find all of those
> inferior to 0 but I suppose we can change it.

Full GCC command line:

```
[  826s] g++ -c -o test_allheaders_allheaders.o 
-I/home/abuild/rpmbuild/BUILD/wxWidgets-3.1.5/lib/wx/include/gtk3-unicode-3.1
-I../include -D_FILE_OFFSET_BITS=64 -I/usr/include/gtk-3.0
-I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount
-I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/uuid
-I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16
-I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0
-I/usr/include/wayland -I/usr/include/libxkbcommon -I/usr/include/atk-1.0
-I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread  -D__WXGTK__  
   -I. -DWXUSINGDLL -I./../samples -I../3rdparty/catch/include -pthread -Wall
-Wundef -Wunused-parameter -Wno-ctor-dtor-privacy -Woverloaded-virtual
-Wno-deprecated-declarations -I/usr/include/freetype2 -I/usr/include/uuid
-I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/harfbuzz -I/usr/include/libmount -I/usr/include/blkid
-I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1
-I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0
-I/usr/include/gtk-3.0/unix-print -I/usr/include/gtk-3.0
-I/usr/include/gio-unix-2.0 -I/usr/include/wayland -I/usr/include/libxkbcommon
-I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0
-I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -I/usr/include/SDL2
-D_REENTRANT -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type
-flto=auto -g -I/usr/include/webkitgtk-4.0 -I/usr/include/libsoup-2.4
-I/usr/include/libxml2 -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 
-fvisibility=hidden -fvisibility-inlines-hidden -fPIC -DPIC  -O2 -Wall
-D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type
-flto=auto -g ./allheaders.cpp
[  826s] In file included from /usr/include/c++/11/deque:67,
[  826s]                  from /usr/include/c++/11/queue:60,
[  826s]                  from ../include/wx/msgqueue.h:24,
[  826s]                  from ./allheaders.h:239,
[  826s]                  from ./allheaders.cpp:435:
```

So definitely neither -Werror=zero-as-null-pointer-constant nor
-Wsystem-headers.


GCC -v
```
Using built-in specs.
Reading specs from /usr/lib64/gcc/x86_64-suse-linux/11/defaults.spec
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d,jit
--enable-offload-targets=nvptx-none,amdgcn-amdhsa, --without-cuda-driver
--enable-host-shared --enable-checking=release --disable-werror
--with-gxx-include-dir=/usr/include/c++/11 --enable-ssp --disable-libssp
--disable-libvtv --enable-cet=auto --disable-libcc1 --enable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-libphobos
--enable-version-specific-runtime-libs --with-gcc-major-version-only
--enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function
--program-suffix=-11 --without-system-libunwind --enable-multilib
--with-arch-32=x86-64 --with-tune=generic
--with-build-config=bootstrap-lto-lean --enable-link-mutex
--build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.1 20211124 [revision 7510c23c1ec53aa4a62705f0384079661342ff7b]
(SUSE Linux) 
```

  parent reply	other threads:[~2022-01-05  3:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28  2:24 [Bug libstdc++/103848] New: std::deque<>::operator- uses "0" for nullptr check, triggers "zero-as-null-pointer-constant" stefan.bruens@rwth-aachen.de
2021-12-28  2:39 ` [Bug libstdc++/103848] [11/12 Regression] std::deque<>::iterator operator- uses "0" for nullptr check, triggers "zero-as-null-pointer-constant" warning pinskia at gcc dot gnu.org
2022-01-04 13:38 ` rguenth at gcc dot gnu.org
2022-01-04 14:31 ` redi at gcc dot gnu.org
2022-01-04 15:15 ` jakub at gcc dot gnu.org
2022-01-04 15:42 ` redi at gcc dot gnu.org
2022-01-04 15:58 ` redi at gcc dot gnu.org
2022-01-04 16:02 ` jakub at gcc dot gnu.org
2022-01-04 16:18 ` redi at gcc dot gnu.org
2022-01-05  3:08 ` stefan.bruens@rwth-aachen.de [this message]
2022-01-05  9:22 ` redi at gcc dot gnu.org
2022-01-05  9:31 ` jakub at gcc dot gnu.org
2022-01-05 13:47 ` cvs-commit at gcc dot gnu.org
2022-04-21  7:51 ` [Bug libstdc++/103848] [11 " rguenth at gcc dot gnu.org
2022-04-21 12:32 ` cvs-commit at gcc dot gnu.org
2022-04-21 12:39 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103848-4-vU8HbGt058@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).