fix Issue 12044 - Invalid code gen causes segfault