Fixed undefined behaviuor in gcc