Reply to post: Re: SSD Auto-Bork

Gospel according to HPE: And lo, on the 32,768th hour did thy SSD give up the ghost

Simon Harris

Re: SSD Auto-Bork

"overflow of a signed int is Undefined Behaviour, and therefore Cannot Happen."

Undefined Behaviour does not mean something Cannot Happen.

It *may* happen, or something else *may* happen depending on the CPU architecture and the whim of the compiler writer in deciding what should happen in such circumstances. For a 2's complement system that doesn't trap overflows wraparound is a common manifestation of 'undefined behaviour' - what happens to a negative time code may also result in other undefined behaviour.

Of course, it could be performing some other form of undefined behaviour on the overflow (e.g. an unexpected exception), or maybe the firmware uses the timecode as an array index in a event status table, and going negative has overwritten critical system information - there are lots of ways it could go wrong!

If you live in a world where you imagine 'undefined behaviour' is something that 'cannot happen' (are you expecting at run-time an error message saying 'this cannot happen'?) you'll miss a lot of error conditions where 'things that cannot happen' do happen.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon