openjdk-1.8.0/GCC-12-reports-some-compiler-warnings.patch

42 lines
2.0 KiB
Diff
Raw Normal View History

2024-04-30 14:11:01 +08:00
Subject: fix GCC 12 fails to compile AArch64 due to -Wstringop-overflow
---
hotspot/make/linux/makefiles/gcc.make | 2 +-
hotspot/src/share/vm/opto/type.cpp | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make
index 7dde7f096..d122f0eae 100644
--- a/hotspot/make/linux/makefiles/gcc.make
+++ b/hotspot/make/linux/makefiles/gcc.make
@@ -212,7 +212,7 @@ ifeq ($(USE_CLANG), true)
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
endif
2024-11-08 10:33:12 +08:00
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual -Wno-stringop-overflow
2024-04-30 14:11:01 +08:00
ifeq ($(USE_CLANG),)
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp
index 58572f137..92d4e6b70 100644
--- a/hotspot/src/share/vm/opto/type.cpp
+++ b/hotspot/src/share/vm/opto/type.cpp
@@ -2553,8 +2553,11 @@ TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int o
_offset >= InstanceMirrorKlass::offset_of_static_fields()) {
// Static fields
assert(o != NULL, "must be constant");
- ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
- ciField* field = k->get_field_by_offset(_offset, true);
+ ciField* field = NULL;
+ if (o != NULL) {
+ ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
+ 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 ||
--
2.22.0