Is it still safe to delete nullptr in c++0x?

5.3.5/7 says: If the value of the operand of the delete-expression is not a null pointer value, the delete-expression will call a deallocation function (3.7.4.2). Otherwise, it is unspecified whether the deallocation function will be called. And 3.7.4.2/3 says: The value of the first argument supplied to a deallocation function may be a null pointer … Read more

Deleting a pointer in C++

1 & 2 myVar = 8; //not dynamically allocated. Can’t call delete on it. myPointer = new int; //dynamically allocated, can call delete on it. The first variable was allocated on the stack. You can call delete only on memory you allocated dynamically (on the heap) using the new operator. 3. myPointer = NULL; delete … Read more

What does Visual Studio do with a deleted pointer and why?

I noticed that the address stored in ptr was always being overwritten with 00008123… This seemed odd, so I did a little digging and found this Microsoft blog post containing a section discussing “Automated pointer sanitization when deleting C++ objects”. …checks for NULL are a common code construct meaning that an existing check for NULL … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)