Hacker News new | past | comments | ask | show | jobs | submit login

I tend to read undefined as don't do it



It's not always possible / feasible to avoid undefined operations.

Use the modulo operator? Undefined unless you checked for negative first.

Add two integers? Undefined unless you check for overflow.

Granted those examples get a pass because on modern two-complement architectures everything handles the undefined behavior in an identical way.


I believe the modulo operator is implementation defined. As should be signed integer overflow, though it isn't.

One big problem about "undefined" is, when some platform go bananas over some stuff, the behaviour is standardised as undefined for all platforms, allowing the compilers to go bananas. Which they do, because every bit of undefined helps them perform some micro-optimization they couldn't do before.

I long for the day where the standard forces compilers to provide options such as -fwrap or -fno-strict on platforms that can reasonably support it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: