If I have something like this
if(pointer!=NULL&&(*pointer)==x) { ... }
Will it segfault if pointer is NULL? If it is compiler specific, I'd like to know how it is in GCC.
No, because of short circuit evaluation.
If the LHS is false, then the RHS won't be evaluated. Therefore, if it's a NULL pointer, it will never hit the RHS and attempt to dereference it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With