[Bug libstdc++/103848] New: std::deque<>::operator- uses "0" for nullptr check, triggers "zero-as-null-pointer-constant"

stefan.bruens@rwth-aachen.de gcc-bugzilla@gcc.gnu.org
Tue Dec 28 02:24:23 GMT 2021


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

            Bug ID: 103848
           Summary: std::deque<>::operator- uses "0" for nullptr check,
                    triggers "zero-as-null-pointer-constant"
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stefan.bruens@rwth-aachen.de
  Target Milestone: ---

Since
https://github.com/gcc-mirror/gcc/commit/f6be5d6ee31b76838e242704782938bc9745659c

using `operator-` may fail:

```
[  346s] In file included from /usr/include/c++/11/deque:67,
[  346s]                  from /usr/include/c++/11/queue:60,
...
[  346s] /usr/include/c++/11/bits/stl_deque.h:356:58: error: zero as null
pointer constant [-Werror=zero-as-null-pointer-constant]
[  346s]   356 |           * (__x._M_node - __y._M_node - int(__x._M_node !=
0))
[  346s]       |                                              ~~~~~~~~~~~~^~~~
[  346s] cc1plus: some warnings being treated as errors
```


More information about the Gcc-bugs mailing list