stack slot missaligned testcase

Jan Hubicka hubicka@horac.ta.jcu.cz
Wed May 19 03:07:00 GMT 1999


Hi
I was thinking a bit about creating testcase for the stack missalignment problem
(latest snapshots missalignes all stack slot that have larger alignment than size
on FRAME_GROWS_DOWNWARD machines).
Here is my testcase. It is i386 specific but, I wasn't able to make something better.
At least I would like to have this testcase in the suite to be sure it is not forgotten.
Missaligned long doubles are quite serious problems on Intel CPUs...
I also believe that other platforms will have large penalties because of this bug as well.

I've sent patch for this bug about three weeks ago. Needless to say that I would love
to see this fixed in 2.95.0


#include <stdio.h>
/* Testcase for proper stack alignment.  */
int
main ()
{
  /*This test works only on i386 with default preffered stack boundary settings, but shows a bug that
    is common to other architectures as well.  */
#ifdef __i386__
  /*All stack slots ought to be aligned. */
  double a1;
  long double a2;
  double a3;
  char *p1 = (char *)&a1;
  char *p2 = (char *)&a2;
  char *p3 = (char *)&a3;

  /* Even if the boundary was missaligned on the entry, the relative
     stack positions ought to be multiples of 8 */
  if ((p1 - p2) & 7)
    abort ();
  if ((p2 - p3) & 7)
    abort ();
#endif
  return 0;
}


More information about the Gcc-bugs mailing list