Hi,
On 16/08/2017 12:09, Daniel Langr wrote:
When compiling the following code:
int* ptr = nullptr;
delete ptr;
I didn't understand why we don't already handle the easy case:
constexpr int* ptr = nullptr;
delete ptr;
and the below tiny front-end tweak would take care of it. But I'm not
sure how much of that we want in the front-end, I would appreaciate a
word from Jason about such kind of early optimization.
Thanks,
Paolo.
////////////////
Index: decl2.c
===================================================================
--- decl2.c (revision 251085)
+++ decl2.c (working copy)
@@ -499,7 +499,7 @@ delete_sanity (tree exp, tree size, bool doing_vec
}
/* Deleting a pointer with the value zero is valid and has no effect. */
- if (integer_zerop (t))
+ if (integer_zerop (fold_non_dependent_expr (t)))
return build1 (NOP_EXPR, void_type_node, t);
if (doing_vec)