Commit 87359037 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/89507 (bogus "size of array exceeds maximum object size")

	PR c++/89507
	* tree.c (valid_constant_size_p): Deal with size INTEGER_CSTs
	with types other than sizetype/ssizetype.

	* g++.dg/other/new2.C: New test.

From-SVN: r269233
parent 1405bf4c
2019-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/89507
* tree.c (valid_constant_size_p): Deal with size INTEGER_CSTs
with types other than sizetype/ssizetype.
2019-02-26 Eric Botcazou <ebotcazou@adacore.com>
* config/sparc/sparc-opts.h (enum processor_type): Rename to...
......
2019-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/89507
* g++.dg/other/new2.C: New test.
PR tree-optimization/89500
* gcc.dg/pr89500.c: New test.
* gcc.dg/Wstringop-overflow-10.c: New test.
......
// PR c++/89507
// { dg-do compile }
unsigned char const n = 128;
int *p = new int[n]; // { dg-bogus "array exceeds maximum object size" }
......@@ -7533,19 +7533,16 @@ valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
return false;
}
tree type = TREE_TYPE (size);
if (TYPE_UNSIGNED (type))
if (tree_int_cst_sgn (size) < 0)
{
if (!tree_fits_uhwi_p (size)
|| tree_int_cst_sign_bit (size))
{
*perr = cst_size_too_big;
return false;
}
*perr = cst_size_negative;
return false;
}
else if (tree_int_cst_sign_bit (size))
if (!tree_fits_uhwi_p (size)
|| (wi::to_widest (TYPE_MAX_VALUE (sizetype))
< wi::to_widest (size) * 2))
{
*perr = cst_size_negative;
*perr = cst_size_too_big;
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment