Get the latest tech news
Undefined Behavior in C and C++ (2024)
behavior in C and C++ February 3, 2024 Working in C or C++ requires some awareness of undefined behavior: what it is, what its effects are, and how to avoid tripping over it. For simplicity, I will just talk about C, but everything in this article also applies to C++ except where otherwise noted.
DEC - PDP-11 - Ken Thompson and Dennis Ritchie, 1970 ca., Gwen Bell artifact and book collection, Lot X7413.2015, Catalog 102685442, Computer History Museum But that would be grounds for making the result of dereferencing a null pointer, implementation-defined, which means A conforming implementation is required to document its choice of behavior. If you decide to use them in a project, I do recommend documenting your reasoning, e.g. whether you did so as a general precaution or because it fixed a particular bug; that information could be difficult for a future maintainer (including you, a couple of years down the line) to recover after the fact. This is usually not a viable option, simply because projects for which it was, have mostly already switched; people have long since realized that when you don't have very hard requirements for performance or low-level control or the ability to work closely with a large existing code base, it's probably easier to use a higher-level language.
Or read this on Hacker News