Re:Defining the Undefinedness of C (2015) [pdf]
by littlestymaar on Thursday July 27, 2017 @10:15AM
(#14865446)
> > Undefined means : the compiler can omit this case and assume it never happens.
> That's not the whole picture though. The standard actually says that anything can happen in undefined cases.
Well, that's right the standard says the compiler can do anything they want, including erasing all data from your hard drive or summoning a demon in your nose [1], but in practice I've never seen any compiler attempt such things.
What compilers usually do with UB is assuming it will never happen and use this invariant as an optimization hint.
> That's not the whole picture though. The standard actually says that anything can happen in undefined cases.
Well, that's right the standard says the compiler can do anything they want, including erasing all data from your hard drive or summoning a demon in your nose [1], but in practice I've never seen any compiler attempt such things.
What compilers usually do with UB is assuming it will never happen and use this invariant as an optimization hint.
[1] : http://catb.org/jargon/html/N/nasal-demons.html