Calling a NULL function pointer dereferences address 0 and transfers control there, on a desktop it segfaults; on an MCU it typically triggers a hard fault, because address 0 is usually flash/the vector table, not valid code. This is a real risk with registered callbacks: if a driver calls a callback the application never registered, and it defaulted to NULL, you crash. So you initialize callback pointers to NULL and null-check before every indirect call. Calling through a pointer whose type doesn't match the actual function, wrong parameter count, wrong types, wrong return, is undefined behavior even if it appears to work, because the calling convention (how arguments are passed in registers/stack) may not line up. The defenses are to keep a single typedef for the signature and ensure every registered function matches it, and to guard indirect calls with null checks.
C Programming · Interview question
What happens if you call a NULL or mismatched function pointer?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Function Pointers & Callbacks
Store a function in a variable, pass behavior as an argument, and build dispatch tables: the mechanism behind qsort, HAL callbacks, and interrupt vector tables.