fixed optimization bug with some gcc versions