On Sun, 17 Apr 2016, Mikhail Maltsev wrote:
Currently GCC can optimize away the following dead store:
void test(char *x)
{
*x = 1;
free(x);
}
but not this one (Clang handles both cases):
void test(char *x)
{
*x = 1;
delete x;
}
The attached patch fixes this by introducing a new __attribute__((free)). I
first tried to add new built-ins for each version of operator delete (there are
four of them), but it looked a little clumsy, and would require some special
handling for warning about taking address of built-in function.
This sounds nice. Mingw* may want to use that attribute for _aligned_free.
I am concerned about what happens when a user replaces a global operator
delete. Does the replacement function have to satisfy the properties for
this attribute?
--
Marc Glisse