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
+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 Eric Botcazou <ebotcazou@adacore.com>
* config/sparc/sparc-opts.h (enum processor_type): Rename to...
2019-02-26 Jakub Jelinek <jakub@redhat.com>
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 tree-optimization/89500
* gcc.dg/pr89500.c: New test.
* gcc.dg/Wstringop-overflow-10.c: New test.
--- /dev/null
+// PR c++/89507
+// { dg-do compile }
+
+unsigned char const n = 128;
+int *p = new int[n]; // { dg-bogus "array exceeds maximum object size" }
- 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;