fix Issue 12044 - Invalid code gen causes segfault
Merge pull request #3257 from WalterBright/fix12044

fix Issue 12044 - Invalid code gen causes segfault