RFR: JDK-8294902: Undefined Behavior in C2 regalloc with null references [v6]

Andrew Haley aph at openjdk.org
Fri Dec 2 11:05:13 UTC 2022


On Fri, 2 Dec 2022 11:00:54 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> src/hotspot/share/utilities/globalDefinitions_gcc.hpp line 155:
>> 
>>> 153:   char* c = (char*)(void*)&dummyObj->field;     \
>>> 154:   return (size_t)(c - space);                   \
>>> 155: }()
>> 
>> I am very surprised this does not produce any warnings! Let me test this on different GCCs...
>
> Of course we can't exclude the possibility of warnings, given that taking the offset of a field of a non-POD class is unspecified behaviour. Having said that, I'm not sure exactly what it'd be warning about.

This restriction in C++ is unnecessary, really, since AFAIK this works on all implementations.

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

PR: https://git.openjdk.org/jdk/pull/10920


More information about the hotspot-dev mailing list