fix issue 4995 - invariant() can violate a function's nothrow