<br><br><div class="gmail_quote">On Tue, Nov 6, 2012 at 10:43 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Nov 6, 2012 at 1:22 PM, Beinan Li <<a href="mailto:li.beinan@gmail.com">li.beinan@gmail.com</a>> wrote:<br>
> Hello LLVM/Clang,<br>
><br>
> With Xcode4.5, llvm/clang:<br>
> Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)<br>
> Target: x86_64-apple-darwin12.2.0<br>
> Thread model: posix<br>
><br>
> we use -fcheck-new in our compiler settings which has been triggering this<br>
> clang warning:<br>
><br>
>> clang: warning: argument unused during compilation: '-fcheck-new'<br>
><br>
><br>
> We wonder if this gcc setting is not supported by clang.<br>
<br>
</div>It is not supported; "argument unused during compilation" is the<br>
generic "I don't know what you're asking for, so I'm ignoring it":<br>
warning.<br>
<br>
-Eli<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br>I would note that on Linux, with overcommit, this is probably useless anyway.<br><br>Unless you grow out of address space, which is hard on 64 bits systems (2^47 bytes of available address space) which would lead the kernel not to allocate memory, the kernel will hand over a pointer to a memory page whenever `malloc` requires it, even though the page itself might be much smaller than the requested block, and the memory in the block will be effectively allocated *when written to* (or read from... I guess).<br>
<br>As such, `malloc` should never return a null pointer, making `std::bad_alloc` a somewhat mystic creature (even with exceptions enabled). And in the worst case, the constructor call (after `new` returned but before your applicative code is handed over the pointer) will write to a memory zone for which no page can be allocated and your program will crash (*).<br>
<br>So, at least on Linux, I would see `-fcheck-new` as a dubious flag.<br><br>-- Matthieu<br><br>(*) Note: there is a oom killer process that is supposed to kill random programs on the machine to free up memory when it is exhausted...<br>