PR c++/67913 - new expression with negative size not diagnosed
commitd5a9b16d1a96dbeae92cfb2acc1ba023dcef0eb0
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Nov 2015 02:23:34 +0000 (10 02:23 +0000)
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Nov 2015 02:23:34 +0000 (10 02:23 +0000)
tree2e5bacc1d2b331365198e4be6156f26598c36370
parentcba2cca776b142dbc64df15a4368f9ad8ffd06eb
PR c++/67913 - new expression with negative size not diagnosed
PR c++/67927 - array new expression with excessive number of elements
               not diagnosed

gcc/cp/
* call.c (build_operator_new_call): Do not assume size_check
is non-null, analogously to the top half of the function.
* init.c (build_new_1): Detect and diagnose array sizes in
excess of the maximum of roughly SIZE_MAX / 2.
Insert a runtime check only for arrays with a non-constant size.
(build_new): Detect and diagnose negative array sizes.

gcc/testsuite/
* init/new45.C: New test to verify that operator new is invoked
with or without overhead for a cookie.
* init/new44.C: New test for placement new expressions for arrays
with excessive number of elements.
* init/new43.C: New test for placement new expressions for arrays
with negative number of elements.
* other/new-size-type.C: Expect array new expression with
an excessive number of elements to be rejected.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230081 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/new43.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/new44.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/new45.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/new-size-type.C