godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.58k stars 21.1k forks source link

`-Werror=array-bounds` warnings raised in `core/math/bvh_structs.inc` #66252

Closed akien-mga closed 2 years ago

akien-mga commented 2 years ago

Godot version

4.0.beta (8e14f9ba21725a9445f3979742f2fc87c8a7b463)

System information

Mageia 9 Linux, x86_64 | GCC 12.2.1 (20220917)

Issue description

When compiling on Linux with GCC 12.2.1 (snapshot from 20220917) with warnings enabled (and werror=yes to treat them as errors), some -Werror=array-bounds warnings are raised in BVH structs. The warnings aren't raised by GCC 10.2.0 - I didn't test with GCC 11.x recently but I remember seeing those warnings for a while so probably any GCC 12.x version might raise them.

g++ -o servers/physics_2d/godot_broad_phase_2d_bvh.linuxbsd.template-release.x86_64.o -c -std=gnu++17 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wplacement-new=1 -Wno-error=cpp -pipe -O3 -Wall -Wextra -Wwrite-strings -Wno-unused-parameter -Wshadow-local -Wno-misleading-indentation -Walloc-zero -Wduplicated-branches -Wduplicated-cond -Wstringop-overflow=4 -Wlogical-op -Wattribute-alias=2 -Werror -Wno-error=return-type -DNO_EDITOR_SPLASH -DTOUCH_ENABLED -DFONTCONFIG_ENABLED -DALSA_ENABLED -DALSAMIDI_ENABLED -DPULSEAUDIO_ENABLED -D_REENTRANT -DDBUS_ENABLED -DSPEECHD_ENABLED -DJOYDEV_ENABLED -DUDEV_ENABLED -DX11_ENABLED -DUNIX_ENABLED -D_FILE_OFFSET_BITS=64 -DVULKAN_ENABLED -DGLES3_ENABLED -DMINIZIP_ENABLED -DZSTD_STATIC_LINKING_ONLY -DUSE_VOLK -DVK_USE_PLATFORM_XLIB_KHR -DGLAD_ENABLED -DGLES_OVER_GL -DHAVE_MNTENT -Ithirdparty/freetype/include -Ithirdparty/libpng -Ithirdparty/glad -Ithirdparty/volk -Ithirdparty/vulkan -Ithirdparty/vulkan/include -Ithirdparty/zstd -Ithirdparty/zlib -Iplatform/linuxbsd -I. -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/speech-dispatcher servers/physics_2d/godot_broad_phase_2d_bvh.cpp
In file included from ./core/math/bvh_tree.h:179,
                 from ./core/math/bvh.h:54,
                 from servers/physics_2d/godot_broad_phase_2d_bvh.h:36,
                 from servers/physics_2d/godot_broad_phase_2d_bvh.cpp:31:
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_set_tree(const BVHHandle&, uint32_t, uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:352:36,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(const BVHHandle&, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:320:42,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(uint32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:176:11,
    inlined from 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:50:14:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_set_tree(const BVHHandle&, uint32_t, uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:352:36,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(const BVHHandle&, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:320:42,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(uint32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:176:11,
    inlined from 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:50:14:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_set_tree(const BVHHandle&, uint32_t, uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:352:36,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(const BVHHandle&, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:320:42,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(uint32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:176:11,
    inlined from 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:50:14:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_set_tree(const BVHHandle&, uint32_t, uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:352:36,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(const BVHHandle&, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:320:42,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::set_tree(uint32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:176:11,
    inlined from 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:50:14:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::set_static(GodotBroadPhase2D::ID, bool)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:174:35,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:201:21,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(uint32_t, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:140:7,
    inlined from 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:43:10:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:174:35,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:201:21,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(uint32_t, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:140:7,
    inlined from 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:43:10:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:174:35,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:201:21,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(uint32_t, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:140:7,
    inlined from 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:43:10:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:174:35,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(BVHHandle, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:201:21,
    inlined from 'void BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::move(uint32_t, const BOUNDS&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:140:7,
    inlined from 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:43:10:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual void GodotBroadPhase2DBVH::move(GodotBroadPhase2D::ID, const Rect2&)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'BVHHandle BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_add(T*, bool, const BOUNDS&, int32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:62:30,
    inlined from 'BVHHandle BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::create(T*, bool, uint32_t, uint32_t, const BOUNDS&, int) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:116:30,
    inlined from 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:37:21:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'BVHHandle BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_add(T*, bool, const BOUNDS&, int32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:62:30,
    inlined from 'BVHHandle BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::create(T*, bool, uint32_t, uint32_t, const BOUNDS&, int) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:116:30,
    inlined from 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:37:21:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
In member function 'BVH_ABB<BOUNDS, POINT>& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_aabb(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:428:16,
    inlined from 'BVHHandle BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_add(T*, bool, const BOUNDS&, int32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:62:30,
    inlined from 'BVHHandle BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::create(T*, bool, uint32_t, uint32_t, const BOUNDS&, int) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:116:30,
    inlined from 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:37:21:
./core/math/bvh_structs.inc:65:29: error: array subscript 4294967295 is above array bounds of 'BVH_ABB<Rect2, Vector2> [128]' [-Werror=array-bounds]
   65 |                 return aabbs[p_id];
      |                        ~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)':
./core/math/bvh_structs.inc:59:22: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::aabbs'
   59 |         BVHABB_CLASS aabbs[MAX_ITEMS];
      |                      ^~~~~
In member function 'uint32_t& BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::TLeaf::get_item_ref_id(uint32_t) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]',
    inlined from 'bool BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::_node_add_item(uint32_t, uint32_t, const BVH_ABB<BOUNDS, POINT>&) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_tree.h:431:23,
    inlined from 'BVHHandle BVH_Tree<T, NUM_TREES, MAX_CHILDREN, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>::item_add(T*, bool, const BOUNDS&, int32_t, uint32_t, uint32_t, bool) [with T = GodotCollisionObject2D; int NUM_TREES = 2; int MAX_CHILDREN = 2; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; bool USE_PAIRS = true; BOUNDS = Rect2; POINT = Vector2]' at ./core/math/bvh_public.inc:62:30,
    inlined from 'BVHHandle BVH_Manager<T, NUM_TREES, USE_PAIRS, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, BOUNDS, POINT, BVH_THREAD_SAFE>::create(T*, bool, uint32_t, uint32_t, const BOUNDS&, int) [with T = GodotCollisionObject2D; int NUM_TREES = 2; bool USE_PAIRS = true; int MAX_ITEMS = 128; USER_PAIR_TEST_FUNCTION = GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>; USER_CULL_TEST_FUNCTION = GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>; BOUNDS = Rect2; POINT = Vector2; bool BVH_THREAD_SAFE = true]' at ./core/math/bvh.h:116:30,
    inlined from 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)' at servers/physics_2d/godot_broad_phase_2d_bvh.cpp:37:21:
./core/math/bvh_structs.inc:74:36: error: array subscript 4294967295 is above array bounds of 'uint32_t [128]' {aka 'unsigned int [128]'} [-Werror=array-bounds]
   74 |                 return item_ref_ids[p_id];
      |                        ~~~~~~~~~~~~^
./core/math/bvh_structs.inc: In member function 'virtual GodotBroadPhase2D::ID GodotBroadPhase2DBVH::create(GodotCollisionObject2D*, int, const Rect2&, bool)':
./core/math/bvh_structs.inc:58:18: note: while referencing 'BVH_Tree<GodotCollisionObject2D, 2, 2, 128, GodotBroadPhase2DBVH::UserPairTestFunction<GodotCollisionObject2D>, GodotBroadPhase2DBVH::UserCullTestFunction<GodotCollisionObject2D>, true, Rect2, Vector2>::TLeaf::item_ref_ids'
   58 |         uint32_t item_ref_ids[MAX_ITEMS];
      |                  ^~~~~~~~~~~~
cc1plus: all warnings being treated as errors
scons: *** [servers/physics_2d/godot_broad_phase_2d_bvh.linuxbsd.template-release.x86_64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:00:09.774]

Steps to reproduce

Minimal reproduction project

No response

lawnjelly commented 2 years ago

Just to confirm am aware and will fix as soon as I get GCC12 installed. :grin:

From what I can see this seems a warning caused because the client input at GodotBroadPhase2DBVH is not checked, if a garbage input was passed to the BVH from the calling code it could cause a crash.

The reason the checks in the BVH are DEV_ENABLED only is because it is hot bottleneck code (it could severely slow down physics etc), but we can probably put some ERR_FAILs in the calling code / API to prevent the warning firing off without much effect on performance. The fact the DEV asserts aren't going off indicates this isn't actually a "live bug" in practice.

lawnjelly commented 2 years ago

Still compiling (5 hours later lol), but I don't seem to be getting this warning at least building the editor with release_debug and warnings=extra, with GCC 12.2.1 (compiled from source).

I followed this guide: https://stackoverflow.com/questions/70835585/how-to-install-gcc-12-on-ubuntu (Although on Linux Mint 20). Confirmed it was compiling with GCC 12.

I'll report whether it shows the warning with command line shown in the steps to reproduce, it terminated before the build was complete due to another warning.

EDIT: Yes it does occur later in the build, no idea why it doesn't appear in the editor build warnings: scons p=linuxbsd tools=no target=release warnings=extra werror=no .. could DEV_ENABLED be enabled during release_debug editor builds?

akien-mga commented 2 years ago

5 hours? That's really weird.

You can't build the editor with target=release, only the template (which is where I saw the warning). I don't think the warning happens with target=release_debug, which probably indicates that it happens with -O3 optimization (release) but not with -O2 (release_debug).

lawnjelly commented 2 years ago

5 hours? That's really weird.

You can't build the editor with target=release, only the template (which is where I saw the warning). I don't think the warning happens with target=release_debug, which probably indicates that it happens with -O3 optimization (release) but not with -O2 (release_debug).

Ah could be the optimization level. Yes most of that was compiling GCC from source though and me figuring out how to get scons to use it. :grinning:

lawnjelly commented 2 years ago

OK I think I've figured out why it's tripping, and can confirm is a false flag: _node_add_item() calls:

ref.item_id = leaf.request_item();
BVH_ASSERT(ref.item_id != BVHCommon::INVALID);

// set the aabb of the new item
leaf.get_aabb(ref.item_id) = p_aabb;

The request_item() could theoretically return -1 (for failing), which would then be passed to leaf.get_aabb() and read out of bounds of the array[128]. However, the logic outside of _node_add_item() ensures that there is room (i.e. request_item() will not fail). This logic is checked with the DEV_ASSERT in case of changing the logic outside the routine causing this error.

We can probably eliminate the warning by returning 0 instead of -1 in the case of non-DEV_ENABLED builds, purely to silence the warning.

I'll double check this can't happen, but I'm pretty sure this is the reason for the warning. It kind of makes sense, but the compiler probably can't account for complex logic from the calling routine.

Indeed a little search indicates this particular type of warning has a lot of bugs: https://stackoverflow.com/questions/72871100/compiler-library-or-user-error-eigenarray-gcc-12-1-array-subscript

EDIT: Yes can confirm swapping return value to 0 fixes the warning, and it should never occur at runtime due to the _logic_choose_item_add_node() creating a new node if the current one is full. Will create a PR. :+1: