http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60902
--- Comment #11 from Markus Trippelsdorf <trippels at gcc dot gnu.org> --- OK I'm down to one function from ./libavcodec/flacdec.c: 208 __attribute__ ((optimize(0))) 209 static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) 210 { 211 int i, tmp, partition, method_type, rice_order; 212 int rice_bits, rice_esc; 213 int samples; 214 215 method_type = get_bits(&s->gb, 2); 216 if (method_type > 1) { 217 av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n", 218 method_type); 219 return AVERROR_INVALIDDATA; 220 } 221 222 rice_order = get_bits(&s->gb, 4); 223 224 samples= s->blocksize >> rice_order; 225 if (samples << rice_order != s->blocksize) { 226 av_log(s->avctx, AV_LOG_ERROR, "invalid rice order: %i blocksize %i\n", 227 rice_order, s->blocksize); 228 return AVERROR_INVALIDDATA; 229 } 230 231 if (pred_order > samples) { 232 av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", 233 pred_order, samples); 234 return AVERROR_INVALIDDATA; 235 } 236 237 rice_bits = 4 + method_type; 238 rice_esc = (1 << rice_bits) - 1; 239 240 decoded += pred_order; 241 i= pred_order; 242 for (partition = 0; partition < (1 << rice_order); partition++) { 243 tmp = get_bits(&s->gb, rice_bits); 244 if (tmp == rice_esc) { 245 tmp = get_bits(&s->gb, 5); 246 for (; i < samples; i++) 247 *decoded++ = get_sbits_long(&s->gb, tmp); 248 } else { 249 for (; i < samples; i++) { 250 *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); 251 } 252 } 253 i= 0; 254 } 255 256 return 0; 257 } 258 Without __attribute__ ((optimize(0))) it gets miscompiled.