Fix GCC build.
This commit is based (not entirely) on a patch submitted by Poitr Kubaj <pkubaj@anongoth.pl> in PR 234251.
PR: 234251