RFR: 8341178: TypeRawPtr::add_offset may be "miscompiled" due to UB [v2]

Kim Barrett kbarrett at openjdk.org
Tue Oct 8 06:25:57 UTC 2024


On Mon, 7 Oct 2024 22:06:24 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Initialization of `TypePtr::NULL_PTR` here:
>> https://github.com/openjdk/jdk/blob/4d50cbb5a73ad1f84ecd6a895045ecfdb0835adc/src/hotspot/share/opto/type.cpp#L538
>
> I saw that too, but it creates a TypePtr, not a TypeRawPtr.

Oh, you are right. And TypeRawPtr::make asserts the PTR is neither Constant nor Null. Which makes
both switch cases under modification here supposedly unreachable. That would explain why I never hit
either after running lots of tests. All of the change proposed here can be eliminated, and instead change
both cases to fall through to the default ShouldNotReachHere(). (And that would be another way to
remove the -Wzero-as-null-pointer-constant warning that was how I got here in the first place. :) )

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21324#discussion_r1791266904


More information about the hotspot-compiler-dev mailing list