How do profile settings effect behavior of code compiled in the standard library?
For example the overflow-checks profile option?
I was debugging something today which I incorrectly thought was an overflow from my code calling Duration::add
. It turns out this wasn't the bug, but it got me thinking... How do profile settings effect overflow behavior of code defined in the standard library?
My understanding before was: if I compiled with overflow-checks = true
all integer overflows (even in std) would cause a panic.
However, I also thought the standard library was pre-built by rustup, so my own compilation flags shouldn't have any effect on std.
By inspecting the source I realized there's no way Duration::add
could overflow as it uses checked_add with expect internally.
Anyone know of a function in the standard library which has different behavior depending on overflow compilation flags?