Add a test to reproduce #8316.