Gcc extra alignment..

Linus Torvalds torvalds@transmeta.com
Tue Oct 31 12:17:00 GMT 2000


On Tue, 31 Oct 2000, Loren James Rittle wrote:
> 
> bar ();
> 
> foo ()
> {
>   do { bar (); } while (0);
> }
> 
> [ deleted ]
> 
> Looks like the padding is still there.

Not just that. When you enable optimizations, the padding goes away, but
it looks like

	foo:
	        subl    $12, %esp
	        call    bar
	        addl    $12, %esp
	        ret

even at -O3 -fomit-frame-pointer.

Now, remove the "do { } while (0)", and the end result is the much more
reasonable (even pretty):

	foo:
	        jmp     bar

So obviously padding isn't the only thing that "do { } while (0)" will do
for you..

(I wonder why. It's not as if we're adding any new variables in scope or
anything like that. Strange. I'm sure it has a perfectly good explanation,
but it does look like some obvious optimization is trivially missed).

		Linus



More information about the Gcc mailing list