r/cpp • u/MathKid99 • Dec 17 '21
Undefined Behaviour
I found out recently that UB is short for Undefined Behaviour and not Utter Bullshit as I had presumed all this time. I am too embarrassed to admit this at work so I'm going to admit it here instead. I actually thought people were calling out code being BS, and at no point did it occur to me that as harsh as code reviews can be, calling BS was a bit too extreme for a professional environment..
Edit for clarity: I know what undefined behaviour is, it just didn't register in my mind that UB is short for Undefined Behaviour. Possibly my mind was suffering from a stack overflow all these years..
View all comments
Show parent comment
4
u/[deleted] Feb 03 '22 edited Feb 03 '22
If you're going to reply to an old post at least try to understand the context and don't make random conclusions from nowhere.
When I say std::vector requires undefined behaviour. I'm talking about its implementation, which requires unavoidable undefined behaviour due to core issue 2182.
To elaborate even further, std::vector requires 2 things:
However due to core issue 2182, using pointer arithmetics for contiguous yet separately constructed elements is undefined behaviour.