Flecs-Rust
Flecs-Rust copied to clipboard
nightly warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique
Build with a current nightly and you'll get this:
warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique
--> flecs_ecs/src/core/utility/functions.rs:521:9
|
521 | ctor_hooks != sys::flecs_default_ctor
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the address of the same function can vary between different codegen units
= note: furthermore, different functions could have the same address after being merged together
= note: for more information visit <https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html>
= note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default
help: refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint
|
521 | !std::ptr::fn_addr_eq(ctor_hooks, sys::flecs_default_ctor as unsafe extern "C-unwind" fn(*mut std::ffi::c_void, i32, *const ecs_type_info_t))
| ++++++++++++++++++++++ ~ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The suggested workaround isn't great since on some targets, you tend to do more LTO and function merging (like wasm32).
I would opt for fn_addr_eq unless you have another solution.
You can, but like I said, in the presence of LTO and function merging, it may well lead to very difficult to detect bugs. But that's up to you.