Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

GDScript: Add ignore macro for the dangling pointer warning raised on the enter_function method

Rafael-Petry1331b9b3a263
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 24bc684d355..c63f78c7183 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -491,7 +491,17 @@ public:
}
call_level->prev = _call_stack;
+
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12
+ GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wdangling-pointer") // The VM code ensures call_level is not freed while it is in use, so this warning is a false positive for GCC 12+.
+#endif
+
_call_stack = call_level;
+
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12
+ GODOT_GCC_WARNING_POP
+#endif
+
call_level->stack = p_stack;
call_level->instance = p_instance;
call_level->function = p_function;