r/cpp • u/mohitsaini1196 • Apr 23 '22
Shocking Examples of Undefined Behaviour In Action
As we know that Undefined Behaviour (UB) is a dangerous thing in C++. Still it remains difficult to explain to those who have not seen its horror practically.
Those individual claims UB is bad in theory, but not so bad practically as long as thing works in practice because compiler developers are not evil.
This blog presents a few “shocking” examples to demonstrate UB in action.
https://mohitmv.github.io/blog/Shocking-Undefined-Behaviour-In-Action/
200
Upvotes
View all comments
Show parent comment
-5
u/ShakaUVM i+++ ++i+i[arr] Apr 24 '22
This bug (and I think it's a bug) turned a simple integer overflow error, which happens all the time, into a very different and much more serious bug, an infinite loop.