fix exception bug for compiler optimization