<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div>Good point, I forgot to check the standard.</div><div>Given the clang was failing I assumed the code was wrong x).</div><div><br class=""></div><div>I am guessing there is something weird with the project, because indeed, paragraph 7.2 of the standard says:</div><div>
                
        
        
                <div class="page" title="Page 181">
                        <div class="layoutArea">
                                <div class="column">
                                        <ol start="0" style="list-style-type: none" class="">
                                                <li class=""><p class=""><span style="font-size: 12.000000pt; font-family: 'Times'" class="">The </span><span style="font-size: 12.000000pt; font-family: 'Courier'; font-weight: 700" class="">assert </span><span style="font-size: 12.000000pt; font-family: 'Times'" class="">macro is redefined according to the current state of </span><span style="font-size: 12.000000pt; font-family: 'Courier'; font-weight: 700" class="">NDEBUG </span><span style="font-size: 12.000000pt; font-family: 'Times'" class="">each time that
</span></p><p class=""><span style="font-size: 12.000000pt; font-family: 'Courier'; font-weight: 700" class=""><assert.h> </span><span style="font-size: 12.000000pt; font-family: 'Times'" class="">is included. </span></p>
                                                </li>
                                        </ol>
                                </div>
                        </div>
                </div><br class=""><blockquote type="cite" class=""><div class="">On Oct 4, 2017, at 2:53 PM, Craig Topper <<a href="mailto:craig.topper@gmail.com" class="">craig.topper@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I thought NDEBUG was what the assert macro also used to decide whether to be an assert or not.</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br class=""><div class="gmail_quote">On Wed, Oct 4, 2017 at 2:41 PM, Quentin Colombet via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> 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;line-break:after-white-space" class="">Hi,<div class=""><br class=""></div><div class="">While audit our code, we found out a strange pattern in one of the LLVM headers and we were wondering if that was expected or if it should be fixed.</div><div class=""><br class=""></div><div class="">Namely the problem looks like this:</div><div class=""><font face="Menlo" style="font-size:11px" class="">#ifndef NDEBUG</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">  // Define some variable.</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">#endif</font></div><div class=""><font face="Menlo" style="font-size:11px" class=""><br class=""></font></div><div class=""><font face="Menlo" style="font-size:11px" class="">assert(/*use this variable, i.e., outside of the ifndef NDEBUG scope*/);</font></div><div class=""><br class=""></div><div class="">This happens in <span style="font-family:Menlo;font-size:11px;background-color:rgb(255,255,255)" class="">include/llvm/IR/<wbr class="">ValueHandle.h </span>for the variable <span style="font-family:Menlo;font-size:11px;background-color:rgb(255,255,255)" class="">Poisoned </span>line 494</div><div class=""><br class=""></div><div class="">This works because when we build LLVM with assert we explicitly disable NDEBUG:</div><div class=""><div class=""><font face="Menlo" style="font-size:11px" class="">if( LLVM_ENABLE_ASSERTIONS )</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">  […]</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">  # On non-Debug builds cmake automatically defines NDEBUG, so we</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">  # explicitly undefine it:</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">  if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )</font></div><div class=""><font face="Menlo" style="font-size:11px" class="">    add_definitions( -UNDEBUG )</font></div></div><div class=""><br class=""></div><div class="">If we use this header in a different project and thus, with potentially different rules for macro definitions, the compiler complains with</div><div class=""><div class=""><font face="Menlo" class=""><span style="font-size:11px" class="">error:   use of undeclared identifier ‘Poisoned'</span></font></div></div><div class=""><font face="Menlo" style="font-size:11px" class=""><br class=""></font></div><div class="">I think the right thing to do is to fix the code to work without the special way of setting the macros, but I’d like people opinions first.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">-Quentin</div></div><br class="">______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>