Add a reduced test case for issue 5291

Re: PR #5409.