Quote Originally Posted by brewbuck View Post
Perfectly valid in the spec maybe, but this is one of those cases where you can't really rely on the spec. Using C++ delete on a null pointer is safe, but calling C free() on a NULL pointer crashes on about half the machines I have access to, specifications notwithstanding.
Some older (prestandard) implementations of the C library were associated with a free() function that would produce unexpected behaviour - often a crash - when supplied with a NULL pointer.

While, theoretically, the standard eliminated this, the situation of a free() function crashing on NULL was quite common practically. This situation continued for several years after the standard, as a flaw in several mainstream compilers/libraries because it was easy to work around and therefore not a high priority fix for compiler/library vendors. It also affected some older (eg during and before the period when the C++ standard was in draft) C++ implementations in which new/delete operators employed malloc()/free() behind the scenes.

Much as idealists will insist otherwise, not every developer has the luxury of upgrading their compilers and libraries to the latest and greatest. The result is that, practically, those who care about portability of code will often avoid calling free() or invoking operator delete with a NULL pointer.