<br><br><div class="gmail_quote">On Tue, Nov 15, 2011 at 8:51 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com">chandlerc@google.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="gmail_quote"><div class="im">On Tue, Nov 15, 2011 at 8:46 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.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="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div><div><br></div></div></div><div>See <a href="http://clang.llvm.org/docs/LanguageExtensions.html#feature_check" target="_blank">http://clang.llvm.org/docs/LanguageExtensions.html#feature_check</a> -- it should be completely compiler neutral. </div>


</div></blockquote><div><br></div></div><div>So, the user code will have to look like this? </div><div><br></div><div>#ifndef __has_feature</div><div># define __has_feature(x) 0</div><div>#endif</div><div>...</div><div><br>

</div>
<div>#if __has_feature(address_sanitizer)</div><div>..</div><div>#endif</div></div></blockquote><div><br></div></div><div>I would hope it could be simplified as:</div><div><br></div><div>#if defined(__has_feature) && __has_feature(address_sanitizer)</div>

<div>...</div><div>#endif</div></div></blockquote><div><br></div><div>What is the status of __has_feature? </div><div>Is it a pure clang extension? </div><div>Is it suggested for standardization? </div><div>If other compilers are not going to accept/implement __has_feature I afraid that the user code will actually have to look like this:</div>
<div><br></div><div>#if defined(__has_feature) && __has_feature(address_sanitizer)</div><div># define ADDRESS_SANITIZER 1</div><div># elif defined(__gcc_analog_of_has_feature) && __gcc_analog_of_has_feature(address_sanitizer)</div>
<div># define ADDRESS_SANITIZER 1</div><div># elif defined(__msvc_analog_of_has_feature) && __msvc_analog_of_has_feature(address_sanitizer)</div><div># define ADDRESS_SANITIZER 1</div><div>#endif</div><div><br></div>
<div>#ifdef ADDRESS_SANITIZER</div><div><code></div><div>#endif</div><div><br></div><div>Argument 'can be easily implemented in gcc' does not work. </div><div>We need something like 'will most likely be accepted by gcc' for any value of 'gcc'.</div>
<div><br></div><div>--kcc </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div><br></div><div>But either way, yes in essence.</div>
<div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote">
<div>Also, is that indeed the right use of __has_feature? Maybe __has_extension fits better?  </div><div>Hm, asan is not an extension nor a (C++ standard) feature. </div></div></blockquote><div><br></div></div><div>This is a good point. I wonder if there needs to be another __has_* macro John? (maybe Doug?) I don't know what to call it. It's a feature which is not related to the standard in any way.</div>

<div><br></div><div>There are other things that I can conceive of wanting to put here: -fcatch-undefined-behavior, -ftrapv, etc...</div></div>
</blockquote></div><br>