...
Some standard library vendors, such as libstdc++, throw a std::logic_error when a null pointer is used in the above function calls, though not when calling std::char_traits::length(). However, std::logic_error is not a requirement of the C++ Standard, and some vendors (libc++ and the Microsoft Visual Studio STL, for example) do not implement this behavior. For portability, you should not rely on this behavior.
...