This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How about arm gcc optimze for if ( ptrToStruct && ptrToStruct ->member )

hi,

I'm using arm-none-eabi-gcc 5.4, I'm not sure if there's problem as followed:

if ( ptr && ptr->member ) {

// do some thing....

}

The question is that, when compiled with -O1 or -O2, CPU will execute the condition (ptr->member) before the judgement ( NULL != ptr ) ???

Parents
  • Hi Xiaofeng,

    Could you share the exact command-line used and a complete preprocessed testcase for us to reproduce your issue? When building with -save-temps a .i (for C file) or .ii (for C++ file) will be produced which contains the preprocessed file.

    Best regards.

Reply
  • Hi Xiaofeng,

    Could you share the exact command-line used and a complete preprocessed testcase for us to reproduce your issue? When building with -save-temps a .i (for C file) or .ii (for C++ file) will be produced which contains the preprocessed file.

    Best regards.

Children