8319818: Address GCC 13.2.0 warnings (stringop-overflow and dangling-pointer)

Reviewed-by: ihse, dholmes
This commit is contained in:
Mikael Vidstedt 2023-11-13 17:46:26 +00:00
parent 3684b4b5f2
commit c0507af5a4
3 changed files with 22 additions and 13 deletions

View File

@ -88,6 +88,13 @@ DISABLED_WARNINGS_gcc := array-bounds comment delete-non-virtual-dtor \
maybe-uninitialized missing-field-initializers parentheses \ maybe-uninitialized missing-field-initializers parentheses \
shift-negative-value unknown-pragmas shift-negative-value unknown-pragmas
ifeq ($(DEBUG_LEVEL), fastdebug)
ifeq ($(call And, $(call isTargetOs, linux) $(call isTargetCpu, aarch64)), true)
# False positive warnings for atomic_linux_aarch64.hpp on GCC >= 13
DISABLED_WARNINGS_gcc += stringop-overflow
endif
endif
DISABLED_WARNINGS_clang := sometimes-uninitialized \ DISABLED_WARNINGS_clang := sometimes-uninitialized \
missing-braces delete-non-abstract-non-virtual-dtor unknown-pragmas missing-braces delete-non-abstract-non-virtual-dtor unknown-pragmas

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -43,6 +43,18 @@ void ResourceArea::bias_to(MEMFLAGS new_flags) {
#ifdef ASSERT #ifdef ASSERT
ResourceMark::ResourceMark(ResourceArea* area, Thread* thread) :
_impl(area),
_thread(thread),
_previous_resource_mark(nullptr)
{
if (_thread != nullptr) {
assert(_thread == Thread::current(), "not the current thread");
_previous_resource_mark = _thread->current_resource_mark();
_thread->set_current_resource_mark(this);
}
}
void ResourceArea::verify_has_resource_mark() { void ResourceArea::verify_has_resource_mark() {
if (_nesting <= 0 && !VMError::is_error_reported()) { if (_nesting <= 0 && !VMError::is_error_reported()) {
// Only report the first occurrence of an allocating thread that // Only report the first occurrence of an allocating thread that

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -193,17 +193,7 @@ class ResourceMark: public StackObj {
#ifndef ASSERT #ifndef ASSERT
ResourceMark(ResourceArea* area, Thread* thread) : _impl(area) {} ResourceMark(ResourceArea* area, Thread* thread) : _impl(area) {}
#else #else
ResourceMark(ResourceArea* area, Thread* thread) : ResourceMark(ResourceArea* area, Thread* thread);
_impl(area),
_thread(thread),
_previous_resource_mark(nullptr)
{
if (_thread != nullptr) {
assert(_thread == Thread::current(), "not the current thread");
_previous_resource_mark = _thread->current_resource_mark();
_thread->set_current_resource_mark(this);
}
}
#endif // ASSERT #endif // ASSERT
public: public: