GDScript: Suppress -Wdangling-pointer warning for Linux Arm64 release templates - #122789
Conversation
|
What I meant by suppressing in my comment on the issue was actually just applying one of our warning suppression macros e.g. Warnings are meant to help us, but if they do get in the way there is no need to jump through hoops for them. In this case I see no reason to switching to a dedicated heap allocation. The VM code ensures that the lifetime of this pointer does not exceed the lifetime of the stack allocated call level, it's just a bit too complicated for the compiler to recognize. There might be a point against relying on such complicated contracts, but for the GDScript VM I think it's worth it. |
8b66154 to
0832058
Compare
|
I must've missed the existence of these macros while looking through the codebase, this is definitely a more reasonable approach. Just fixed my changes accordingly. Thanks for the tip! |
|
Maybe runners use older GCC, so that's why it errors? Not fully sure. The error from CI checks: I think you can try to see if GDScriptLanguage::CallLevel call_level;
GDScriptLanguage::CallLevel* call_level_ptr = &call_level; // Suppress -Wdangling-pointer GCC warning.
GDScriptLanguage::get_singleton()->enter_function(call_level_ptr, p_instance, this, stack, &ip, &line);will also suppress it. |
|
I tested your idea and it didn't work unfortunately, it raised the initial dangling pointer warning. You were correct on the version mismatch of the runner though. The build-linux job runs on ubuntu-22.04, which uses gcc-11 by default. The Therefore, I think the way to go would be to just check if the GCC version >= 12 before using the suppressing macros, such as: #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 12
GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wdangling-pointer") // The VM 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
#endifIf that is a good approach, for what I could see, it both fixes the warning issue when compiling with more recent versions of GCC and also doesn't break compilation for older versions. Thanks! |
0832058 to
292efb2
Compare
HolonProduction
left a comment
There was a problem hiding this comment.
LGTM to me beside the comment nitpick 👍
Not exactly an expert on this whole gcc macro stuff, but it seems sane to me and passes CI, so it should be fine.
015b12c to
e73c1eb
Compare
… the enter_function method
e73c1eb to
1331b9b
Compare
|
Thanks! Congratulations on your first merged contribution! 🎉 |
What problem(s) does this PR solve?
-Wdangling-pointerwarning for Linux Arm64 release templates #118150Additional information
It changes the declaration of the
call_levelvariable to be inside the enter_function method, using the memnew function (it is freed on the exit_function method, using memdelete). It also changes the enter_function's signature, as the call_level pointer is not passed as a parameter anymore.No AI assistance was used on this PR.
This is also my first PR, so any considerations are very much welcome :)
Tests
scons target=template_release werror=yesand it finished compiling