Skip to content

Commit a3b10aa

Browse files
Kun Wangkuenking
authored andcommitted
8329826: GCC 12 reports some compiler error when building jdk8
1 parent c1c8064 commit a3b10aa

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

hotspot/make/linux/makefiles/adlc.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CXXFLAGS += -DASSERT
6666

6767
# CFLAGS_WARN holds compiler options to suppress/enable warnings.
6868
# Compiler warnings are treated as errors
69-
CFLAGS_WARN = $(WARNINGS_ARE_ERRORS)
69+
CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) -Wno-register
7070
CFLAGS += $(CFLAGS_WARN)
7171

7272
OBJECTNAMES = \

hotspot/make/linux/makefiles/gcc.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ ifeq ($(USE_CLANG), true)
212212
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
213213
endif
214214

215-
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type
215+
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Wno-stringop-overflow
216216

217217
ifeq ($(USE_CLANG),)
218218
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit

hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2935,13 +2935,20 @@ void ConcurrentMark::print_reachable(const char* str,
29352935
return;
29362936
}
29372937

2938-
char file_name[JVM_MAXPATHLEN];
2938+
// fix gcc 12 build jdk8 fastdebug compiler error:
2939+
// directive writing up to 4096 bytes into a region of size between 0 and 4096 [-Werror=format-overflow=]
2940+
char *file_name = (char *) NEW_C_HEAP_ARRAY(char, strlen(G1PrintReachableBaseFile) + 2 + strlen(str), mtGC);
2941+
if (NULL == file_name) {
2942+
gclog_or_tty->print_cr(" #### error: NEW_C_HEAP_ARRAY failed.");
2943+
return;
2944+
}
29392945
sprintf(file_name, "%s.%s", G1PrintReachableBaseFile, str);
29402946
gclog_or_tty->print_cr(" dumping to file %s", file_name);
29412947

29422948
fileStream fout(file_name);
29432949
if (!fout.is_open()) {
29442950
gclog_or_tty->print_cr(" #### error: could not open file");
2951+
FREE_C_HEAP_ARRAY(char, file_name, mtGC);
29452952
return;
29462953
}
29472954

@@ -2957,6 +2964,7 @@ void ConcurrentMark::print_reachable(const char* str,
29572964

29582965
gclog_or_tty->print_cr(" done");
29592966
gclog_or_tty->flush();
2967+
FREE_C_HEAP_ARRAY(char, file_name, mtGC);
29602968
}
29612969

29622970
#endif // PRODUCT

hotspot/src/share/vm/opto/type.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,8 +2553,11 @@ TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int o
25532553
_offset >= InstanceMirrorKlass::offset_of_static_fields()) {
25542554
// Static fields
25552555
assert(o != NULL, "must be constant");
2556-
ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
2557-
ciField* field = k->get_field_by_offset(_offset, true);
2556+
ciField* field = NULL;
2557+
if (o != NULL) {
2558+
ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
2559+
field = k->get_field_by_offset(_offset, true);
2560+
}
25582561
assert(field != NULL, "missing field");
25592562
BasicType basic_elem_type = field->layout_type();
25602563
_is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT ||

0 commit comments

Comments
 (0)