3 ms·
That's exactly what I mean about UB in C. I mean I agree with you If you don't know exactly what your compiler will do with the UB, (or if you ever might want t
by grayhatter 6y ago
That's exactly what I mean about UB in C. I mean I agree with you If you don't know exactly what your compiler will do with the UB, (or if you ever might want to use a different compiler and or comp options) you probably want to avoid writing any UB. But it's not magic, and it can't time travel. That segment makes explicit that UB doesn't need to create a sequence point around UB. This is important because if it did need to do that (to protect the non-UB code) the compiler would need to keep a list of all UB. I'm pretty sure that if you're going to create a list of all undefined behavior, you might as well just define it. It's not magic, it's just allowing the compiler to YOLO it, using optimizations it already knows how to do.
I have a really cool example of how/why this is actually a good thing for compilers if you're interested.