3 ms·
The OP is offering terrible advice based on a falsehood they believe about null pointers. In many applications (including the STM32H743 microcontroller that I a
by nickff 2y ago
The OP is offering terrible advice based on a falsehood they believe about null pointers. In many applications (including the STM32H743 microcontroller that I am currently working on), address zero (which is how "NULL" is defined by default in my IDE) points to RAM or FLASH. In my current application, NULL is ITCM (instruction tightly coupled memory), and it's where I've put my interrupt vector table. If I read it, I don't get an error, but I may get dangerously wrong data.
- pfyra 2y agoI work with the same mcu. You can set up the MPU to catch null pointer dererences so they don't pass silently.
- russdill 2y agoNot only that, if you're referencing an element in a very large structure or array, the base address may be zero, but the actual access may be several pages past that.
- LorenPechtel 2y agoI disagree. You're looking at embedded code which very well might not be running with memory segmentation. If you have no hardware safety you must check your pointers, period. But few of us are in that situation. Personally, I haven't touched an environment without hardware safety in 20 years.