https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67913
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- Author: msebor Date: Tue Nov 10 02:23:34 2015 New Revision: 230081 URL: https://gcc.gnu.org/viewcvs?rev=230081&root=gcc&view=rev Log: 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. Added: trunk/gcc/testsuite/g++.dg/init/new43.C trunk/gcc/testsuite/g++.dg/init/new44.C trunk/gcc/testsuite/g++.dg/init/new45.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c trunk/gcc/cp/init.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/other/new-size-type.C