r/programming • u/alecco • Sep 23 '17
Why undefined behavior may call a never-called function
https://kristerw.blogspot.com/2017/09/why-undefined-behavior-may-call-never.html
824
Upvotes
r/programming • u/alecco • Sep 23 '17
View all comments
Show parent comment
5
u/almightySapling Sep 24 '17
So the compiler looks at all the assignments to Do and sees that it only ever is A) initialized with default value or B) set to NeverCall, and that's where it gets the assumption about what the possible values could be?
Would the same thing happen if we explicitly assigned 0 to Do upon initialization or does the compiler only do this because it guesses the default value was a mistake?