[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.8.1/gcc/ipa-inline-analysis.c.~1~ 2013-01-10 21:38:27.000000000 +0100 +++ gcc-4.8.1/gcc/ipa-inline-analysis.c 2013-08-17 11:44:42.225456145 +0200 @@ -337,7 +337,7 @@ add_clause (conditions conditions, struc and thus there is no point for looking for them. */ 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 =