From c382eb192afa367a50496288014c1a50ec3957ba Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Sat, 20 May 2023 21:57:02 -0600 Subject: [PATCH] AP_Param: Switch from type punning to defined behavior * This was undefined behavior in the C++ standard * Use the safer options in AP_Common * Removes a compiler warning Signed-off-by: Ryan Friedman --- libraries/AP_Param/AP_Param.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index b91ed5a354..42e47470ce 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -3019,7 +3019,7 @@ bool AP_Param::add_param(uint8_t _key, uint8_t param_num, const char *pname, flo // check CRC auto &hinfo = const_cast(info.group_info)[0]; - const int32_t crc = *(const int32_t *)(&hinfo.def_value); + const auto crc = to_int32(hinfo.def_value); int32_t current_crc; if (load_int32(key, 0, current_crc) && current_crc != crc) {