Problems using Vector Extensions

Brian Dessent brian@dessent.net
Sat Sep 8 11:15:00 GMT 2007


Thomas Unterthiner wrote:

> > This could be due to the object not being aligned to a 16 byte
> > boundary.  Gcc relies on the platform's crt startup files to align the
> > stack properly prior to main(), so you should check if that is
> > happening.  After that point gcc should keep it aligned from there on.
> >
> How can I check for proper stack-alignment? (I am terribly bad at
> assembly, so should any asm be required a code-snippet would be great).

I would just fire up a debugger, put a breakpoint at main, and look at
$esp at that point.

> I tried compiling using using "-mpreferred-stack-boundary=4" and using
> the aligned-attribute when defining the Vector3D-class, but neither did
> solve the problem.

Yeah, no compiler switches are going to be able to fix it if the stack
starts out aligned wrong.  gcc's idea of aligning the stack means always
pushing/popping/adjusting esp in multiples of the desired alignment, but
not actually ever adjusting the absolute value of esp.  For performance
reasons there is an implicit agreement that the startup code will handle
this.

Brian



More information about the Gcc-help mailing list