On 23/03/2011 14:11, Warren Young wrote:
> Some of the language in the Standard allows the
> implementation to cause monkeys to fly out the USB port.
>
> One way to react to that possibility is to wrap all uses of
> unspecified library behavior with an infinite series of
> conditionals:
>
> if (monkeys_fly_out_of_the_usb_port()) {
> ...
> }
> else if (phase_of_the_moon_is_waxing_gibbous()) {
> ...
> }
>
> A more reasonable reaction is to learn the actual behavior
> of our tools and make reasoned decisions about how likely
> those behaviors are to change. If the likelihood is low,
> assume the behavior won't change.
The most realistic and practical way to deal with UB (which
is what you are talking about) is to *not write UB code*.
Making assumptions about how an environment will respond to
your UB code is total suicide and will lead to your product
crashing on your customer, perhaps months down the line. And
it's ridiculously easy to avoid.
Tom