On 04/01/2016 09:11 AM, Jakub Jelinek wrote:
Hi!
The new warn_placement_new_too_small function blindly assumes that
if {DECL,TYPE}_SIZE_UNIT is non-NULL, then it must be INTEGER_CST
that fits into uhwi. That is not the case, it could be a VLA, etc.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?
OT, as I said in bugzilla, I see very questionable code in that function
too, no idea what Martin meant with that:
while (TREE_CODE (oper) == COMPONENT_REF)
{
tree op0 = oper;
while (TREE_CODE (op0 = TREE_OPERAND (op0, 0)) == COMPONENT_REF);
if (TREE_CODE (op0) == VAR_DECL)
var_decl = op0;
oper = TREE_OPERAND (oper, 1);
}
TREE_OPERAND (oper, 1) of a COMPONENT_REF should be always a FIELD_DECL,
so this will never loop. Did you mean to use if instead of while, something
different?
Or perhaps TREE_OPERAND (oper, 0)?
2016-04-01 Jakub Jelinek <ja...@redhat.com>
Marek Polacek <pola...@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.
* g++.dg/init/new47.C: New test.
OK.
jeff