Good lord. If anyone depends all versions of GCC to not optimize this away,
they are going to hate life. Since GCC doesn't seem to do cross file
optimization (does it?) I've found the following works well:
cat > use_result.c
int dummy; // can't be static, the compiler will see it's not read
use_result(int i)
{
dummy = i;
}
^D
for (i = 0; i < N; ++i) use_result(i);
I'm positive we do stuff like this in LMbench, which is fairly well supported
on a pile of different platforms/compilers.
----- Larry McVoy lm at bitmover.com http://www.bitmover.com/lm - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/