<div dir="auto"><div>When I forwarded this to our team, William suggested to add a new jcheck test to warn about this. I'm not familiar with the new git-jcheck, but at a first glance, this looks like an interesting opportunity to me.</div><div dir="auto"><br></div><div dir="auto">What do you think?<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">Kim Barrett <<a href="mailto:kim.barrett@oracle.com">kim.barrett@oracle.com</a>> schrieb am Di., 26. Nov. 2024, 01:26:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/25/24 7:16 AM, Kennke, Roman wrote:<br>
> Is it possible - and would it make sense - to mechanically forbit NULL? E.g. by re-defining it in a central place, just like we do for other stuff like constuctors for certain things?<br>
I don't think so.<br>
<br>
Redefining it in a way that makes it unusable seems problematic because it<br>
might affect non-HotSpot code. An example where I'm pretty sure this <br>
would be<br>
a problem is gtest.<br>
<br>
Redefining it in a way that still works, as is currently done for <br>
Windows (see<br>
JDK-8324686) doesn't prevent adding new uses.<br>
<br>
Something like the suggestion in JDK-8343802 is the only viable approach <br>
I've<br>
been able to come up with.  I've seen discussion that maybe there should <br>
be a<br>
gcc -Wnull-as-null-pointer-constant (alongside the existing<br>
-Wzero-as-null-pointer-constant), but that doesn't currently exist, and <br>
would<br>
only help for gcc-based platforms.<br>
<br>
clang-tidy has modernize-use-nullptr: "The check converts the usage of null<br>
pointer constants (e.g. NULL, 0) to use the new C++11 and C23 nullptr<br>
keyword."  Perhaps something could be built on that? Doing so is likely more<br>
work than the grep-based approach suggested in JDK-8343802.<br>
<br>
</blockquote></div></div></div>