Will the compiler auto optimize the if statement?

I have a question about whether the compiler will auo optimize the if statement.
E.g:

case 1 :
if (conditionA && conditionB)
{
do something
}

case 2 :
if (conditionA)
{
if (condtionB)
{
do something
}
}

It is easy to understand both case do the same thing. But my question is, in case 1, if conditionA is false, will conditionB still be calculated or not ??

There will be similar case for "||" which if conditonA is true.

Thank you.


But my question is, in case 1, if conditionA is false, will conditionB still be calculated or not ??


Short circuit evaluation. In A && B ,if A is false, B will not be evaluated. Similarly, for A || B, if A is true, B will not be evaluated.
Thank you !
Topic archived. No new replies allowed.