[Bug c++/70488] [6 Regression] ICE in tree.c:7345 triggered by warning of placement new too small on VLA
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Apr 1 12:19:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70488
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I believe we should add these two checks:
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2430,7 +2430,8 @@ warn_placement_new_too_small (tree type, tree nelts, tree
size, tree oper)
though the size of a member of a union may be viewed as extending
to the end of the union itself (it is by __builtin_object_size). */
if ((TREE_CODE (oper) == VAR_DECL || use_obj_size)
- && DECL_SIZE_UNIT (oper))
+ && DECL_SIZE_UNIT (oper)
+ && valid_constant_size_p (DECL_SIZE_UNIT (oper)))
{
/* Use the size of the entire array object when the expression
refers to a variable or its size depends on an expression
@@ -2438,7 +2439,8 @@ warn_placement_new_too_small (tree type, tree nelts, tree
size, tree oper)
bytes_avail = tree_to_uhwi (DECL_SIZE_UNIT (oper));
exact_size = !use_obj_size;
}
- else if (TYPE_SIZE_UNIT (TREE_TYPE (oper)))
+ else if (TYPE_SIZE_UNIT (TREE_TYPE (oper))
+ && valid_constant_size_p (TYPE_SIZE_UNIT (TREE_TYPE (oper))))
{
/* Use the size of the type of the destination buffer object
as the optimistic estimate of the available space in it. */
before calling tree_to_uhwi on those *_SIZE_UNITs.
More information about the Gcc-bugs
mailing list