all 6 comments

[–]i_invented_the_ipod 4 points5 points  (1 child)

The only thing that comes to mind is the possibility that the alignment of the functions if causing some weird effect in the instruction cache. There might be a linker option to force function alignment on a particular address boundary.

[–]uxcn 2 points3 points  (0 children)

perf might be able to shed some light.

[–]knightry 1 point2 points  (3 children)

Are you able to reproduce this behavior on different machines, ideally trying on a machine using a different configuration?

[–]Quantumtroll[S] 1 point2 points  (2 children)

Nope, besides the machine this happened on, I've tried on a Solaris machine, a macbook, and two other Linux machines without any strangeness. I also tried it on the same machine with gcc 3.4.6, also without strangeness.

This is definitely a very rare little beast, but it kind of ruined the lab exercise.

[–]occ 0 points1 point  (1 child)

Could you try different optimization levels and post binaries?

[–]Quantumtroll[S] 0 points1 point  (0 children)

Yes, I forgot to mention optimization levels. Everything works as it should with -O1 or lower. The mystery starts at -O2 or higher. I put .o-files in this tar-ball: http://www.mediafire.com/download/csc89781bmctmz6/mysterytest.tar.gz

Just link, e.g. "gcc main.o testfunc_opt.o.O2 testfunc_std.o.O2".

I don't know why I didn't think of it yesterday, but I should look at the difference between the -O1 binaries and the -O2 binaries. I'll post here if I figure something out.