 No idea. 16.04 is too old… … But if you have a lot of time then you can check whether it's a bug in optimizer. … First check if it works with -O0. Of it does then check with -O1. After that enable/disable individual optimizations and find which one is the culprit. Then revert to -O2 and disable only it.