Regression test for #5061.