Fix bug with using undefined behavior

Worked on windows, but not on linux