[backport gcc-4.9/trunk r201719 ] List-Archive: Date: Tue, 13 Aug 2013 14:20:49 +0200 From: Marek Polacek Subject: [PATCH] Quash undefined behavior in ipa-inline-analysis.c When doing bootstrap with -fsanitize=undefined, I noticed undefined behavior in this file. We basically do 1 << 32, since NUM_CONDITIONS is #defined to 32, which is not defined. I admit I didn't followed the algorithm at all, but this patch passed bootstrap + regtesting on x86_64-linux. So, ok for trunk? gcc/ 2013-08-14 Marek Polacek * ipa-inline-analysis.c (add_clause): Avoid shifting integer NUM_CONDITIONS bit positions. --- gcc-4.7.3/gcc/ipa-inline-analysis.c.~1~ 2012-05-26 11:37:17.000000000 +0200 +++ gcc-4.7.3/gcc/ipa-inline-analysis.c 2013-08-17 11:47:05.995300285 +0200 @@ -304,7 +304,7 @@ add_clause (conditions conditions, struc if (cc1->code == CHANGED || cc1->code == IS_NOT_CONSTANT) continue; - for (c2 = c1 + 1; c2 <= NUM_CONDITIONS; c2++) + for (c2 = c1 + 1; c2 < NUM_CONDITIONS; c2++) if (clause & (1 << c2)) { condition *cc1 = VEC_index (condition,