[jdk8u-dev] RFR: 8329826: GCC 12 reports some compiler error when building jdk8
Kun Wang
kwang at openjdk.org
Wed May 8 13:20:56 UTC 2024
On Tue, 7 May 2024 18:01:32 GMT, mirabilos <duke at openjdk.org> wrote:
>> (disclaimer: I am not a reviewer)
>> This proposed change doesn't really handle the case where o == NULL, although it makes the compiler happy. I propose something like:
>>
>> assert(o != NULL, "must be constant");
>> if (o != NULL) {
>> ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
>> ciField* field = k->get_field_by_offset(_offset, true);
>> assert(field != NULL, "missing field");
>> BasicType basic_elem_type = field->layout_type();
>> _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||
>> basic_elem_type == T_ARRAY);
>> } else {
>> _is_ptr_to_narrowoop = (?? I am not familiar enough with this code to put a suggestion here)
>> }
>
> No, don’t `assert` *and* `if` something. (The compiler may delete one of these two under Undefined Behaviour rules.)
>
> I’ve not looked at the callers, but returning an error or throwing an exception if `o == NULL` would be best. Do **not** rely on `assert`.
This is a good suggestion, I will try to fix it, refer to https://github.com/openjdk/jdk/blob/ad78b7fa67ba30cab2e8f496e4c765be15deeca6/src/hotspot/share/opto/type.cpp#L3560C3-L3572
thanks.
-------------
PR Review Comment: https://git.openjdk.org/jdk8u-dev/pull/479#discussion_r1594020122
More information about the jdk8u-dev
mailing list