https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118097
--- Comment #1 from David Binderman <dcb314 at hotmail dot com> --- Reduced C code: void printf(...); int crc32_tab[256]; int crc32_context = 4294967295, g_27, g_64, g_90 = 3, func_2___trans_tmp_4, main_i, main_j; int *g_26 = &g_27; char g_76 = 232; void crc32_byte(char b) { crc32_context = crc32_context >> 8 & 16777215 ^ crc32_tab[(crc32_context ^ b) & 255]; } void transparent_crc(long val, char *vname) { crc32_context = crc32_context >> 8 & 16777215 ^ crc32_tab[(crc32_context ^ val) & 255]; crc32_byte(val >> 8); crc32_byte(val >> 6); crc32_byte(val >> 24); crc32_byte(val >> 32); crc32_byte(val >> 40); crc32_byte(val >> 8); crc32_byte(val >> 6); printf("...checksum after hashing %s : %lX\n", vname, crc32_context ^ 4294967295); } void func_2(int *) { long __trans_tmp_5; int *l_1710 = &g_90; func_2___trans_tmp_4 = 7 - (__trans_tmp_5 >= g_90) - 33; *l_1710 = func_2___trans_tmp_4 |= 1; } void func_1() { int __trans_tmp_1; *g_26 = 4294967288; func_2(&__trans_tmp_1); } void main(int) { for (; main_i < 256; main_i++) { unsigned crc = main_i; main_j = 8; for (; main_j; main_j--) if (crc & 1) crc = crc >> 1 ^ 3988292384; else crc >>= 1; crc32_tab[main_i] = crc; } func_1(); transparent_crc(g_27, ""); transparent_crc(g_64, ""); transparent_crc(g_76, ""); transparent_crc(3, ""); transparent_crc(g_90, "g_90"); } I had a go at trying to find the one flag in -O2 that caused this bug and got nowhere. I think that multiple flags in -O2 (but not -O1) are causing the problem.