[llvm-bugs] [Bug 36476] [InstCombine] Instcombine deletes call of 'new' function that has side effects after r325630
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 22 13:32:09 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36476
Richard Smith <richard-llvm at metafoo.co.uk> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|NEW |RESOLVED
CC| |richard-llvm at metafoo.co.uk
--- Comment #1 from Richard Smith <richard-llvm at metafoo.co.uk> ---
C++ [expr.new]p10 (http://eel.is/c++draft/expr.new#10) explicitly permits this
optimization:
"An implementation is allowed to omit a call to a replaceable global allocation
function ([new.delete.single], [new.delete.array]). When it does so, the
storage is instead provided by the implementation"
If you want to observe side-effects of your '::operator new(size_t)'
implementation (eg, when writing tests for your allocator), you need to make a
regular function call, rather than using a new-expression. LLVM will not delete
the 'operator new' call here:
S *s = new (::operator new(sizeof(S))) S;
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180222/d1b29060/attachment.html>
More information about the llvm-bugs
mailing list