]> gcc.gnu.org Git - gcc.git/commit
c++: Reject ordered comparison of null pointers [PR99701]
authorMarek Polacek <polacek@redhat.com>
Fri, 16 Jul 2021 19:58:01 +0000 (15:58 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 27 Jul 2021 15:38:59 +0000 (11:38 -0400)
commitbee2f80b901d73f50275f2b44932067ffcf616ca
tree36072f98168cd54913f966c53cb37b88320873e4
parent7ffba77d01a2445c73ec487ba350c7fbf75a4500
c++: Reject ordered comparison of null pointers [PR99701]

When implementing DR 1512 in r11-467 I neglected to reject ordered
comparison of two null pointers, like nullptr < nullptr.  This patch
fixes that omission.

DR 1512
PR c++/99701

gcc/cp/ChangeLog:

* cp-gimplify.c (cp_fold): Remove {LE,LT,GE,GT_EXPR} from
a switch.
* typeck.c (cp_build_binary_op): Reject ordered comparison
of two null pointers.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/nullptr11.C: Remove invalid tests.
* g++.dg/cpp0x/nullptr46.C: Add dg-error.
* g++.dg/cpp2a/spaceship-err7.C: New test.
* g++.dg/expr/ptr-comp4.C: New test.

libstdc++-v3/ChangeLog:

* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
Move a line...
* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
...here.  New test.
gcc/cp/cp-gimplify.c
gcc/cp/typeck.c
gcc/testsuite/g++.dg/cpp0x/nullptr11.C
gcc/testsuite/g++.dg/cpp0x/nullptr46.C
gcc/testsuite/g++.dg/cpp2a/spaceship-err7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/expr/ptr-comp4.C [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc
libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded2.cc [new file with mode: 0644]
This page took 0.065336 seconds and 5 git commands to generate.