The draft C++ standard lists some requirements on library functions using the phrase "mandates". For example, [util.smartptr.shared.cast] says this about std::static_pointer_cast
:
template<class T, class U>
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
[...]
Mandates: The expression
static_cast<T*>((U*)nullptr)
is well-formed.
Is the compiler required to give an error if this condition isn't met (for example if T
is char
and U
is int
), or is it just undefined behavior? [structure.sepcifications] defines "mandates" conditions as rendering the program ill-formed if not met, but it's not clear to me if that must result in an error.