Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A bit pointless example, because that "int y..." is going to be pruned away anyways, since the result is not used anywhere.

Hence it won't trigger any undefined behavior.



The program still contains undefined behavior. It is probably a matter of order of optimization whether the compiler catches the undefined behavior before it elides the useless statement.

But it is certainly 'legal' for the compiler to consider that statement to invoke undefined behavior, and prune any branch that is guaranteed to reach that statement.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: