On 2/13/20 8:35 PM, Kim Barrett wrote: > I don't think this is the right way to address this problem. > > I think the JDK-8238281 change to offset_of and the associated > addition of -Wno-invalid-offsetof to the build configuration was a > mistake, and should be reverted. Those changes seem unrelated to the > purpose of JDK-8238281, which was to raise the minimum acceptable gcc > version.
Alternatively, this works as well: glaubitz@gcc202:~/jdk-hg$ hg diff diff -r 274a0bcce99d src/hotspot/cpu/sparc/macroAssembler_sparc.hpp --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Sat Feb 15 17:35:57 2020 +0800 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.hpp Sat Feb 15 21:05:10 2020 +0300 @@ -485,12 +485,12 @@ void print(outputStream* s); - static int i_offset(int j) { return offset_of(RegistersForDebugging, i[j]); } - static int l_offset(int j) { return offset_of(RegistersForDebugging, l[j]); } - static int o_offset(int j) { return offset_of(RegistersForDebugging, o[j]); } - static int g_offset(int j) { return offset_of(RegistersForDebugging, g[j]); } - static int f_offset(int j) { return offset_of(RegistersForDebugging, f[j]); } - static int d_offset(int j) { return offset_of(RegistersForDebugging, d[j / 2]); } + static int i_offset(int j) { return offset_of(RegistersForDebugging, i) + j * sizeof(((RegistersForDebugging*)16)->i[0]); } + static int l_offset(int j) { return offset_of(RegistersForDebugging, l) + j * sizeof(((RegistersForDebugging*)16)->l[0]); } + static int o_offset(int j) { return offset_of(RegistersForDebugging, o) + j * sizeof(((RegistersForDebugging*)16)->o[0]); } + static int g_offset(int j) { return offset_of(RegistersForDebugging, g) + j * sizeof(((RegistersForDebugging*)16)->g[0]); } + static int f_offset(int j) { return offset_of(RegistersForDebugging, f) + j * sizeof(((RegistersForDebugging*)16)->f[0]); } + static int d_offset(int j) { return offset_of(RegistersForDebugging, d) + (j / 2) * sizeof(((RegistersForDebugging*)16)->d[0]); } // gen asm code to save regs static void save_registers(MacroAssembler* a); What about this approach? Alternatively, with C++11, this should work as well: #include <utility> static int i_offset(int j) { return offset_of(RegistersForDebugging, i) + j * sizeof(std::declval<RegistersForDebugging>().i[0]); } Comments? Adrian -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer - glaub...@debian.org `. `' Freie Universitaet Berlin - glaub...@physik.fu-berlin.de `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913