Does overflowing a uint16_t on 32 bit MCUs just work by treating it as a size_t/uint32_t? This function works on 8 bit AVR microcontrollers, but those have their own assembler implementation rather than the C++... 🤷
Conversation
Notices
-
Embed this notice
Captain Ventilation (be@floss.social)'s status on Monday, 30-Dec-2024 11:57:58 JST Captain Ventilation -
Embed this notice
Captain Ventilation (be@floss.social)'s status on Monday, 30-Dec-2024 11:57:59 JST Captain Ventilation I'm translating some C++ to Rust and the original C++ code silently relies on unsigned integer overflow just... somehow working for this math??? 🙃 This function has tests which I've also translated to Rust, and the only way I can get the tests to pass is by preventing overflow using wider integer types in the intermediate math... u16::overflowing_mul does not do the trick so I don't understand how the C++ code is working??? 🤔
alcinnz repeated this.
-
Embed this notice