3 ms·
Dereferencing NULL, in a C program, is ALWAYS undefined behavior. The fact that you are using a Cortex-M processor does not change this fact. It is spelled ou
by klodolph 11y ago
Dereferencing NULL, in a C program, is ALWAYS undefined behavior. The fact that you are using a Cortex-M processor does not change this fact. It is spelled out very clearly in the C standard.
- masklinn 11y ago> Dereferencing NULL, in a C program, is ALWAYS undefined behavior. 1. you're not required to use C 2. an extension to the C standard can decide to define that behaviour
- cygx 11y agoAlso note that null pointers may not need to be represented by the all-zero bit pattern, ie the conversion (void*)(intptr_t)0 can in principle be more involved than a noop.
- silon7 11y agoI've used at times it to crash the program (core dump), producing a cleaner stack than abort().
- astrange 11y agoYou should use __builtin_trap(). Invoking undefined behavior lets the compiler justifiably delete the entire code path leading up to it.