PR c++/60760 - arithmetic on null pointers should not be allowed in constant
authorMartin Sebor <msebor@redhat.com>
Sat, 30 Jul 2016 22:36:56 +0000 (22:36 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Sat, 30 Jul 2016 22:36:56 +0000 (16:36 -0600)
commit8bada5cd4e51feb60e1e887ecf0bda3288949af4
tree550fac33b2921668ad6de96d6b6f2290e64f48de
parentd0047a2538bc3381a7cf94e714f05b4b96799f6d
PR c++/60760 - arithmetic on null pointers should not be allowed in constant

PR c++/60760 - arithmetic on null pointers should not be allowed in constant
PR c++/71091 - constexpr reference bound to a null pointer dereference

gcc/cp/ChangeLog:

PR c++/60760
PR c++/71091
        * constexpr.c (cxx_eval_binary_expression): Reject invalid expressions
        involving null pointers.
        (cxx_eval_component_reference): Reject null pointer dereferences.
        (cxx_eval_indirect_ref): Reject indirecting through null pointers.
        (cxx_eval_constant_expression): Reject invalid expressions involving
        null pointers.

gcc/testsuite/ChangeLog:

PR c++/60760
PR c++/71091
* g++.dg/cpp0x/constexpr-cast.C: New test.
        * g++.dg/cpp0x/constexpr-nullptr-2.C: New test.
        * g++.dg/cpp1y/constexpr-sfinae.C: Correct.
        * g++.dg/ubsan/pr63956.C: Correct.

From-SVN: r238909
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/constexpr-sfinae.C
gcc/testsuite/g++.dg/ubsan/pr63956.C