From 8f31af3ff955dabba0d7d68916291cf015606535 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Sat, 16 Jan 2016 00:51:17 -0500 Subject: [PATCH] - Work around issue with tree-loop-vectorize in p_acs.cpp. --- src/p_acs.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 87641efe2..6f136d98b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -1954,11 +1954,14 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) int arraynum = MapVarStore[LittleLong(chunk[2])]; if ((unsigned)arraynum < (unsigned)NumArrays) { - int initsize = MIN (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4); + // Use unsigned iterator here to avoid issue with GCC 4.9/5.x + // optimizer. Might be some undefined behavior in this code, + // but I don't know what it is. + unsigned int initsize = MIN (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4); SDWORD *elems = ArrayStore[arraynum].Elements; - for (i = 0; i < initsize; ++i) + for (unsigned int j = 0; j < initsize; ++j) { - elems[i] = LittleLong(chunk[3+i]); + elems[j] = LittleLong(chunk[3+j]); } } chunk = (DWORD *)NextChunk((BYTE *)chunk);