aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
274 stars 58 forks source link

Fix strict-alias warnings #84

Open winterheart opened 3 months ago

winterheart commented 3 months ago

reinterpret_cast on pointers break strict-aliasing rule (-Wstrict-aliasing). Implemented internal function copy_reinterpret_cast that memcpy pointer into type, that can be converted to desired type.

Closes https://github.com/aseprite/aseprite/issues/4413

I agree that my contributions are licensed under the MIT License. You can find a copy of this license at https://opensource.org/licenses/MIT

aseprite-bot commented 3 months ago

clang-tidy review says "All clean, LGTM! :+1:"

dacap commented 2 months ago

Thanks @winterheart, I've just tested and this change segfaults one of our userdata_codec.lua tests where these functions are used:

Testing scripts...
Running scripts/userdata_codec.lua
run-tests.sh: line 69:  1690 Segmentation fault      $ASEPRITE -b --script $script > $t/tmp 2>&1

image