Commit 0f875435 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/70488 (ICE in tree.c:7345 triggered by warning of placement new too small on VLA)

	PR c++/70488
	* init.c (warn_placement_new_too_small): Test whether
	DECL_SIZE_UNIT or TYPE_SIZE_UNIT are integers that fit into uhwi.

	* g++.dg/init/new47.C: New test.

Co-Authored-By: Marek Polacek <polacek@redhat.com>

From-SVN: r234676
parent 41d14659
2016-04-01 Jakub Jelinek <jakub@redhat.com>
Marek Polacek <polacek@redhat.com>
PR c++/70488
* init.c (warn_placement_new_too_small): Test whether
DECL_SIZE_UNIT or TYPE_SIZE_UNIT are integers that fit into uhwi.
2016-04-01 Nathan Sidwell <nathan@acm.org> 2016-04-01 Nathan Sidwell <nathan@acm.org>
PR c++/68475 PR c++/68475
......
...@@ -2430,7 +2430,8 @@ warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper) ...@@ -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 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). */ to the end of the union itself (it is by __builtin_object_size). */
if ((TREE_CODE (oper) == VAR_DECL || use_obj_size) if ((TREE_CODE (oper) == VAR_DECL || use_obj_size)
&& DECL_SIZE_UNIT (oper)) && DECL_SIZE_UNIT (oper)
&& tree_fits_uhwi_p (DECL_SIZE_UNIT (oper)))
{ {
/* Use the size of the entire array object when the expression /* Use the size of the entire array object when the expression
refers to a variable or its size depends on an 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) ...@@ -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)); bytes_avail = tree_to_uhwi (DECL_SIZE_UNIT (oper));
exact_size = !use_obj_size; exact_size = !use_obj_size;
} }
else if (TYPE_SIZE_UNIT (TREE_TYPE (oper))) else if (TYPE_SIZE_UNIT (TREE_TYPE (oper))
&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (oper))))
{ {
/* Use the size of the type of the destination buffer object /* Use the size of the type of the destination buffer object
as the optimistic estimate of the available space in it. */ as the optimistic estimate of the available space in it. */
......
2016-04-01 Jakub Jelinek <jakub@redhat.com>
Marek Polacek <polacek@redhat.com>
PR c++/70488
* g++.dg/init/new47.C: New test.
2016-04-01 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> 2016-04-01 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/70496 PR target/70496
......
// PR c++/70448
// { dg-do compile }
// { dg-options "-Wall" }
typedef __typeof__ (sizeof 0) size_t;
void *operator new (size_t, void *p) { return p; }
void *operator new[] (size_t, void *p) { return p; }
struct S { size_t s; };
void bar (S *);
void
foo (unsigned int s)
{
char t[sizeof (S) + s];
S *f = new (t) S;
bar (f);
f = new (t) S[1];
bar (f);
}
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