| ▲ | Aurornis 11 hours ago | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
I never would have guessed that the unreachable() function would get executed in that example. Probably not something you’d encounter in practice, though I have seen some weird things happen with layers of #ifdef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | saghm 9 hours ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
That's kind of what you get with UB; the compiler doesn't need to do what you expect. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | mathisfun123 9 hours ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
> Probably not something you’d encounter in practice it's actually probably the most common footgun you'll encounter in practice: non-void functions with no return statements just keep executing past their end. ask me how i know. compile with -Wreturn-type if you want to avoid such things... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||