Fix real assumption for gamma function. Fixes #8657.