<div dir="ltr">Ew. So for `MemoryService::create_MemoryUsage_obj` it's effectively adding stuff after the return statement, causing the compiler to complain. I think for `MemoryService::create_MemoryUsage_obj` that last CHECK should probably be changed to THREAD since it's not useful and the code added after the return is unreachable. And LEAVE should probably be changed to not have the return statement wrapped in an arbitrary if statement with JNI_TRUE as the expression, unless there is a reason for that.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 20, 2023 at 10:34 AM Stuart Monteith <<a href="mailto:stuart.monteith@arm.com">stuart.monteith@arm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
   While looking at ASAN to try to reproduce another issue with ASAN, I tried building OpenJDK configured with:<br>
       --enable-asan --with-debug-level=slowdebug<br>
<br>
However, there is a compilation problem that persists up to and include GCC 12.2.0:<br>
        <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80959" rel="noreferrer" target="_blank">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80959</a><br>
<br>
As slowdebug builds are built with -O0, this results in code to be inserted by the macros LEAVE() and CHECK_NH+CHECK_ <br>
macros to be not optimised away. This causes the following two warnings/errors:<br>
<br>
  * For target hotspot_variant-server_libjvm_objs_memoryService.o:<br>
jdk/src/hotspot/share/services/memoryService.cpp: In static member function 'static Handle <br>
MemoryService::create_MemoryUsage_obj(MemoryUsage, JavaThread*)':<br>
jdk/src/hotspot/share/services/memoryService.cpp:219:1: error: control reaches end of non-void function <br>
[-Werror=return-type]<br>
<br>
  * For target support_native_java.base_libjli_java.o:<br>
jdk/src/java.base/share/native/libjli/java.c: In function 'JavaMain':<br>
jdk/src/java.base/share/native/libjli/java.c:556:1: error: control reaches end of non-void function [-Werror=return-type]<br>
   556 | }<br>
       | ^<br>
<br>
<br>
There are a couple of ways of working around this. One is to  change create_MemoryUsage_obj and libjli/java.c to place a <br>
return statement at the end of the function block, after the macros. The changes are straightforward, but we're <br>
obviously not guaranteed to not reintroduce the problem elsewhere.<br>
<br>
Another is to pass:  "--disable-warnings-as-errors" or more specifically "--with-extra-cflags=-Wno-return-type <br>
--with-extra-cxxflags=-Wno-return-type" to configure. This would be a manual process, unless the make files were changed <br>
to handle this, however this does remove the return type checks.<br>
<br>
<br>
Part of the reason for sending this is to at least document the issue publicly. Are there any opinions on what should to <br>
be done next?<br>
<br>
<br>
Stuart<br>
<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><span><br><table border="0" cellspacing="0" cellpadding="0" style="margin:0px;padding:20px 0px 0px;font-family:"Times New Roman""><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td valign="top" style="padding:0px 20px 0px 0px;vertical-align:top;border-right:1px solid rgb(213,213,213)"><img src="https://www.gstatic.com/images/branding/product/1x/googleg_64dp.png" alt="Google Logo" width="72" style="margin: 0px; padding: 0px; display: block; height: auto;"></td><td style="padding:0px 0px 0px 20px"><table border="0" cellspacing="0" cellpadding="0" style="margin:0px;padding:0px"><tbody style="margin:0px;padding:0px"><tr style="margin:0px;padding:0px"><td colspan="2" style="padding:1px 0px 5px;font-family:Arial,Helvetica,Verdana,sans-serif;font-size:13px;line-height:13px;color:rgb(56,58,53);font-weight:700">Justin King</td></tr><tr style="margin:0px;padding:0px"><td colspan="2" style="padding:0px 0px 5px;font-family:Arial,Helvetica,Verdana,sans-serif;font-size:11px;line-height:13px;color:rgb(56,58,53)">Software Engineer</td></tr><tr style="margin:0px;padding:0px"><td colspan="2" style="padding:0px 0px 5px;font-family:Arial,Helvetica,Verdana,sans-serif;font-size:11px;line-height:13px;color:rgb(56,58,53)"><a href="mailto:jcking@google.com" target="_blank">jcking@google.com</a></td></tr></tbody></table></td></tr></tbody></table><table style="border:none;border-collapse:collapse"><colgroup><col width="85"><col width="539"></colgroup><tbody><tr style="height:0pt"><td style="border-width:1pt;border-style:solid;border-color:rgb(255,255,255);vertical-align:middle;padding:4.32pt"></td><td style="border-width:1pt;border-style:solid;border-color:rgb(255,255,255);vertical-align:middle;padding:4.32pt"><br></td></tr></tbody></table></span></div></div>