On Sun, 22 May 2022 03:15:20 GMT, Kim Barrett <kbarr...@openjdk.org> wrote:
>> Like the others, it is caused by `Array::at_put()`. >> >> >> In file included from >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/oops/annotations.hpp:28, >> from >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/oops/instanceKlass.hpp:29, >> from >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/classfile/javaClasses.hpp:30, >> from >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/precompiled/precompiled.hpp:35: >> In member function 'void Array<T>::at_put(int, const T&) [with T = unsigned >> char]', >> inlined from 'void ConstantPool::tag_at_put(int, jbyte)' at >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/oops/constantPool.hpp:126:64, >> inlined from 'void ConstantPool::symbol_at_put(int, Symbol*)' at >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/oops/constantPool.hpp:362:15, >> inlined from 'void >> ClassFileParser::mangle_hidden_class_name(InstanceKlass*)' at >> /home/ysuenaga/github-forked/jdk/src/hotspot/share/classfile/classFileParser.cpp:5966:21: > > `Array<T>::_data` is a pseudo flexible array member. "Pseudo" because C++ > doesn't have flexible array members. The compiler is completely justified in > complaining about the apparently out-of-bounds accesses. > > There is a "well-known" (though moderately ugly) approach to doing flexible > array members in C++. Something like this: > > > T* data() { > return reinterpret_cast<T*>( > reinterpret_cast<char*>(this) + data_offset()); > } > > > where `data_offset()` is new and private: > > > static size_t data_offset() { > return offset_of(Array, _data); > } > > > Use `data()` everywhere instead of using `_data` directly. > > There are other places in HotSpot that use this kind of approach. Thanks @kimbarrett for your advice! Warnings from array.hpp have gone with your suggestion. ------------- PR: https://git.openjdk.java.net/jdk/pull/8646