Made fail_bounds_check more careful with strings.

Fixes GH #11976.