logoalt Hacker News

jcalvinowenstoday at 11:53 AM1 replyview on HN

> It surprises me that the compiler doesn't still take the inference from the assert and just disable emitting the code to perform the check.

The compiler isn't as clever as I think you're envisioning: assert() only works that way because it exits the control flow if the statement isn't true.


Replies

ralferootoday at 11:57 AM

My point is that even though the assert() is optimised out, the compiler could still assume that the condition is valid.

show 1 reply