On 7/26/16 2:44 PM, Timon Gehr wrote:
On 26.07.2016 17:44, Johan Engelen wrote:
The compiler can assume it is unreachable code, but it has to keep it,

That makes no sense. Those two statements are mutually exclusive.

I thought that assert(0) means that the compiler does not need to check any validity of code after the assert. I'd reword Johan's statement to say that the compiler can assume the programmer thought this was unreachable, so it can just crash. It can't compile the crash out, or then the program is in an invalid state!

This is not the user saying "I guarantee we won't go over the cliff", it's the user saying "If we get to this point, I have lost all guarantees of not going off the cliff, so shut off the engine". The compiler can make optimization assumptions for the code that *doesn't* take the branch, but it still needs the branch to make sure.

-Steve

Reply via email to