Regehr: GCC 4.8 Breaks Broken SPEC 2006 Benchmarks
Posted Mar 24, 2013 1:01 UTC (Sun) by
iabervon (subscriber, #722)
In reply to:
Regehr: GCC 4.8 Breaks Broken SPEC 2006 Benchmarks by butlerm
Parent article:
Regehr: GCC 4.8 Breaks Broken SPEC 2006 Benchmarks
The point is that GCC doesn't think you'll actually reach the undefined behavior part of the loop. Say you've got:
static inline int framelen(char s[]) {
for (int i = 0; i < 256; i++) {
if (!s[i])
return i;
}
return i;
}
If you call this with a nul-terminated char array, or any array of at least 256 chars, it is well-defined. If you call it with a nul-terminated array of less than 256 chars, it will be faster if it uses an unconditional branch. It assumes that the programmer has some good reason to believe that short arrays are nul-terminated, which the compiler can't necessarily figure out.
(
Log in to post comments)