From 553289cc1962af0f6f34759029c3fe1296b5e324 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Fri, 17 Oct 2025 15:21:57 -0500 Subject: [PATCH] Core: Sidestep GCC false-positives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit acdb8667b56a43db6eee9a96ad61147bb80ea785) Adds some more fixes for 4.5. Co-authored-by: Rémi Verschelde --- core/io/image.cpp | 7 +++++++ core/math/geometry_2d.cpp | 7 +++++++ scene/resources/packed_scene.cpp | 1 + 3 files changed, 15 insertions(+) diff --git a/core/io/image.cpp b/core/io/image.cpp index 45f9599cbe38..d717c46f39a2 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2391,6 +2391,10 @@ void Image::initialize_data(const char **p_xpm) { } break; case READING_PIXELS: { int y = line - colormap_size - 1; +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wstringop-overflow=0" +#endif for (int x = 0; x < size_width; x++) { char pixelstr[6] = { 0, 0, 0, 0, 0, 0 }; for (int i = 0; i < pixelchars; i++) { @@ -2405,6 +2409,9 @@ void Image::initialize_data(const char **p_xpm) { } _put_pixelb(x, y, pixel_size, data_write, pixel); } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif if (y == (size_height - 1)) { status = DONE; diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp index 376d5d0b43be..9269c5990c3a 100644 --- a/core/math/geometry_2d.cpp +++ b/core/math/geometry_2d.cpp @@ -30,7 +30,14 @@ #include "geometry_2d.h" +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Walloc-zero" +#endif #include "thirdparty/clipper2/include/clipper2/clipper.h" +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #include "thirdparty/misc/polypartition.h" #define STB_RECT_PACK_IMPLEMENTATION #include "thirdparty/misc/stb_rect_pack.h" diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index e550a5beff90..a0bbf743ad76 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -157,6 +157,7 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const { const NodeData *nd = &nodes[0]; Node **ret_nodes = (Node **)alloca(sizeof(Node *) * nc); + ret_nodes[0] = nullptr; // Sidesteps "maybe uninitialized" false-positives on GCC. bool gen_node_path_cache = p_edit_state != GEN_EDIT_STATE_DISABLED && node_path_cache.is_empty();