https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102772
--- Comment #26 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> --- > --- Comment #25 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > Ah, sorry, my fault apparently. > pushl %ebx > movl %gs:0, %ebx > addl $s@ntpoff, %ebx > popl %ebx > ret I messed this up myself: didn't thing apparently ;-) > of course doesn't make sense, because when it is a function, it should return > the value in %eax, while the above computes something into %ebx and overwrites > it and then just returns an uninitialized reg. > So we need: > pushl %ebx > movl %gs:0, %ebx > addl $s@ntpoff, %ebx > movl %ebx, %eax > popl %ebx > ret With that change, foo () and foob () always return the same result.