[cfe-dev] -fcheck-new not supported by LLVM/clang
rjmccall at apple.com
Fri Nov 9 18:18:42 PST 2012
On Nov 6, 2012, at 1:22 PM, Beinan Li wrote:
> With Xcode4.5, llvm/clang:
> Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
> Target: x86_64-apple-darwin12.2.0
> Thread model: posix
> we use -fcheck-new in our compiler settings which has been triggering this clang warning:
> clang: warning: argument unused during compilation: '-fcheck-new'
> We wonder if this gcc setting is not supported by clang.
> gcc spec seems to say that without this the only mechanism against heap allocation returning null pointers
> is through exceptions. However, we disabled exceptions for performance requirements. So this setting
> is important to us.
> Currently we have to use -Qunused-arguments to suppress the warnings, but
> the real question is whether or not it is safe to work without -fcheck-new if it's not supported by clang.
> From web search, we also found the following links which implies that it could be a bug in LLVM/clang:
> If -fcheck-new is an important feature for you (and not a workaround for an old gcc
> problem), please feel free to file a bug at http://llvm.org/bugs/
> Except for the -fcheck-new option, Clang seems to understand all the other compiler options used during the HotSpot build process. For -fcheck-new a warning is issued advertising that the option will be ignored. So I just removed it frommake/linux/makefiles/clang.make. I have also removed obvious workarounds for some older GCC versions in the new Clang files which were derived from their corresponding GCC counterparts.
> There was a longer discussion around the fix for the CHECK macros
> about one and a half years ago. I started a patch that time but than
> somehow forgot about it. Now with the new compiler (and the old
> warnings) I remembered about it. I hope to get it done this time and
> to send it out for review soon. Thank you for the offer to take care
> about it.
> Anybody has any comments?
If at all possible, you should declare your allocation function with an empty exception specification ("throw()"), which is the standards-compliant way of forcing this null-checking behavior. Otherwise, it should be straightforward for even a newcomer to clang to add the -fcheck-new flag and alter IR-generation to honor it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev