Hacker News new | ask | show | jobs
by xchkr1337 1283 days ago
In my opinion the presence of undefined behavior in the C/C++ specification makes it no better than the "specification by implementation" approach
2 comments

C/C++ "undefined behavior" means your program is wrong and not within the spec, not that different compiler implementations might differ. There is no scenario in which any code with UB is valid, regardless of what compiler implementation you use. That's very different. (And IMHO a horrible feature of the spec, but it's there for historical reasons.)

C/C++ spec does have some "implementation defined behavior", which is where you can't rely on what will happen unless you know what compiler you're targeting. They are explicitly listed out as such, and not that common.

without a specification you can never tell with certainty if there's a bug