From 19ac1875ab75a3896615ff1015767baed07d7cd0 Mon Sep 17 00:00:00 2001 From: Karim Shamazov Date: Wed, 26 Aug 2026 16:46:37 +0300 Subject: [PATCH] static constexpr array_inner_control empty_array[1] --- .../core/core-types/decl/array_decl.inl | 2 +- .../core/core-types/definition/array.inl | 22 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/runtime-common/core/core-types/decl/array_decl.inl b/runtime-common/core/core-types/decl/array_decl.inl index d8833313dc..fd3b71e0f1 100644 --- a/runtime-common/core/core-types/decl/array_decl.inl +++ b/runtime-common/core/core-types/decl/array_decl.inl @@ -134,7 +134,7 @@ private: inline static size_t estimate_size(int64_t& new_int_size, bool is_vector); inline static array_inner* create(int64_t new_int_size, bool is_vector); - inline static array_inner* empty_array() __attribute__((always_inline)); + inline static const array_inner* empty_array() __attribute__((always_inline)); inline void dispose(); diff --git a/runtime-common/core/core-types/definition/array.inl b/runtime-common/core/core-types/definition/array.inl index ce1270adae..cf8c4727bf 100644 --- a/runtime-common/core/core-types/definition/array.inl +++ b/runtime-common/core/core-types/definition/array.inl @@ -104,10 +104,10 @@ bool array::is_int_key(const typename array::key_type& key) { } template<> -inline typename array::array_inner* array::array_inner::empty_array() { +inline const typename array::array_inner* array::array_inner::empty_array() { // need this hack because gcc10 and newer complains about // "array subscript is outside array bounds of array::array_inner" - static array_inner_control empty_array[1]{{ + static constexpr array_inner_control empty_array[1]{{ true, ExtraRefCnt::for_global_const, -1, @@ -115,12 +115,12 @@ inline typename array::array_inner* array::array_inner::empty_ 0, 2, }}; - return static_cast::array_inner*>(&empty_array[0]); + return static_cast::array_inner*>(&empty_array[0]); } template -typename array::array_inner* array::array_inner::empty_array() { - return reinterpret_cast(array::array_inner::empty_array()); +const typename array::array_inner* array::array_inner::empty_array() { + return reinterpret_cast(array::array_inner::empty_array()); } template @@ -869,7 +869,7 @@ template template void array::copy_from(const array& other) { if (other.empty()) { - p = array_inner::empty_array(); + p = const_cast(array_inner::empty_array()); return; } @@ -900,7 +900,7 @@ template template void array::move_from(array&& other) noexcept { if (other.empty()) { - p = array_inner::empty_array(); + p = const_cast(array_inner::empty_array()); return; } @@ -944,7 +944,7 @@ array array::convert_from(const array& other) { template array::array() - : p(array_inner::empty_array()) {} + : p(const_cast(array_inner::empty_array())) {} template array::array(const array_size& s) @@ -966,7 +966,7 @@ array::array(const array& other) noexcept template array::array(array&& other) noexcept : p(other.p) { - other.p = array_inner::empty_array(); + other.p = const_cast(array_inner::empty_array()); } template @@ -1004,7 +1004,7 @@ array& array::operator=(array&& other) noexcept { if (this != &other) { destroy(); p = other.p; - other.p = array_inner::empty_array(); + other.p = const_cast(array_inner::empty_array()); } return *this; } @@ -1040,7 +1040,7 @@ array::~array() { template void array::clear() { destroy(); - p = array_inner::empty_array(); + p = const_cast(array_inner::empty_array()); } template