This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/34921] New: Misalign stack variable referenced by nested function


> cat nested-2.c
#include <stdio.h>
#include <stdlib.h>
typedef int aligned __attribute__((aligned(16)));
int global;

void
check (int *i)
{
  *i = 20;
  if ((((int) i) & (__alignof__(aligned) - 1)) != 0)
    {
      printf("\nUnalign address (%d): %p!\n",
             __alignof__(aligned), i);
      abort ();
    }
}

void
foo (void)
{
  aligned jj;
  void bar ()
    {
      jj = -20;
    }
  jj = 0;
  bar ();
  check (&jj);
}

int
main()
{
  foo ();
  return 0;
}
> gcc -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /home/wlin5/gcc/src-daily/configure
--enable-languages=c,c++,fortran --disable-bootstrap
Thread model: posix
gcc version 4.3.0 20080106 (experimental) [trunk revision 131347] (GCC) 
> gcc -m32 -o nested-2.exe nested-2.c
> ./nested-2.exe

Unalign address (16): 0xffa137dc!
Aborted


-- 
           Summary: Misalign stack variable referenced by nested function
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Joey dot ye at intel dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34921


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]