<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On Nov 18, 2014, at 6:40 AM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" class="">timurrrr@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">$ cat test.cpp</div><div class="">#define MY_ASSERT(cond) ((cond)? (void)0 : (void)1)</div><div class="">#define BUG(description) MY_ASSERT(!description)</div><div class=""><br class=""></div><div class="">void foo (int some_condition)</div><div class="">{</div><div class="">  if (some_condition)</div><div class="">    BUG("oh this is broken");</div><div class="">}</div><div class="">$ clang -Werror -Wstring-conversion -c test.cpp</div></div></blockquote><div><br class=""></div><div>I see, warning requires -Wstring-conversion  which is off by default.</div>This warning has always been there in c++ mode.</div><div>My patch has brought this warning to c. I think the warning is correct.</div><div>Can you fix the builedbot by casting the string to “const char*”?</div><div><br class=""></div><div>- Fariborz</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="">test.cpp:7:9: error: implicit conversion turns string literal into bool:</div><div class="">      'const char [18]' to 'bool' [-Werror,-Wstring-conversion]</div><div class="">    BUG("oh this is broken");</div><div class="">    ~~~~^~~~~~~~~~~~~~~~~~~~</div><div class="">test.cpp:2:37: note: expanded from macro 'BUG'</div><div class="">#define BUG(description) MY_ASSERT(!description)</div><div class="">                                    ^</div><div class="">test.cpp:1:27: note: expanded from macro 'MY_ASSERT'</div><div class="">#define MY_ASSERT(cond) ((cond)? (void)0 : (void)1)</div><div class="">                          ^</div><div class="">1 error generated.</div><br class=""><div class="gmail_quote">On Mon Nov 17 2014 at 9:01:09 PM jahanian <<a href="mailto:fjahanian@apple.com" class="">fjahanian@apple.com</a>> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 17, 2014, at 7:18 AM, Timur Iskhodzhanov <<a href="mailto:timurrrr@google.com" target="_blank" class="">timurrrr@google.com</a>> wrote:</div><br class=""><div class="">Hi,<br class=""><br class="">This has broken our -Werror internal build.<div class="">One specific thing that I consider a [noisy] false positive:</div><div class=""><br class=""></div><div class="">#define MY_ASSERT(cond) ((cond)? (void)0 : blah)</div><div class="">#define BUG(description) MY_ASSERT(!description)</div><div class="">...</div><div class="">if (some_condition)</div><div class="">  BUG("oh this is broken")<br class=""></div></div></blockquote></div><br class=""><div class=""><br class=""></div></div><div style="word-wrap:break-word" class=""><div class="">I cannot reproduce this warning. This is the test I used:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;font-family:Menlo" class="">#define MY_ASSERT(cond) ((cond)? (void)0 : (void)1)</div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">#define BUG(description) MY_ASSERT(!description)</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">void foo (int some_condition)</div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">{</div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">  if (some_condition)</div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">    BUG("oh this is broken");</div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">}</div></div><div style="margin:0px;font-size:11px;font-family:Menlo" class=""><br class=""></div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">Can you give a test case producing the warning?</div><div style="margin:0px;font-size:11px;font-family:Menlo" class=""><br class=""></div><div style="margin:0px;font-size:11px;font-family:Menlo" class="">- Fariborz</div><div style="margin:0px;font-size:11px;font-family:Menlo" class=""><br class=""></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></div></div></body></html>