Regression test for #5112