On Tue, 30 Jul 2019, Martin Liška wrote:

On 7/30/19 1:35 PM, Marc Glisse wrote:
+          /* Some delete operators have size as 2nd argument.  */

Some delete operators have 3 arguments. From cp/decl.c:

            /* operator delete (void *, size_t, align_val_t); */


Yep, I know. The patch I installed expects at least 2 arguments:

+                 /* Some delete operators have size as 2nd argument.  */
+                 if (is_delete_operator && gimple_call_num_args (stmt) >= 2)

True, I guess I am a bit confused why the second argument (which could be either size or alignment) needs special handling (mark_operand_necessary) while the third one does not (it is usually a constant).

I tried to experiment to understand, but it is complicated because including <new> disables the optimization:

#include <new>
void fn1() {
    char*p=new char;
    delete p;
}

This ICEs with -O -std=c++17:

int a = 64;
std::align_val_t b{64};
void fn1() {
  void *s = operator new(a,b);
  operator delete(s,8+*(unsigned long*)s,b);
}


--
Marc Glisse

Reply via email to