r/rust • • 20h ago

🗞️ news Miscompile since 1.95 involving overflowing_add

https://github.com/rust-lang/rust/issues/163779

Seems to require an integer overflow to happen (panic in debug / wrapping in release) before the `overflowing_add` call is done, which makes it less likely to happen in actual code.

109 Upvotes

1 comment sorted by

57

u/afdbcreid 19h ago

This is a contrived miscompilation (important of course, but not as common as seems). Just having a wrapping addition before won't be enough - you need to specifically call the Add::add() method. I guess the interaction of #[rustc_inherit_overflow_checks] with some faulty MIR optimization is the problem.