The following C program should print "369", and return a zero exit status.
It does not work on 64-bit Windows Vista.  Instead, it crashes before
the printf, and returns exit status 5.  This is, I assume, because
trampolines do not work.  I guess the protection bits for stack pages need
to be set to allow "execute" when trampolines are present.

The program works on x86-64 linux.

Compiled with "gcc trampoline.c".

Note that this is not legal C code.  It uses the gcc-specific nested-function
extension.

#include <stdio.h>
#include <assert.h>

int f (void (*action) (void))
{   
    (*action)();
}

int g (void)
{   
    int local = 123;

    void nested (void)
    {   
        local = local + 246;
    }

    f (&nested);
    printf ("%d\n", local);

    assert (local == 369);
}

int main (void)
{   
    g();
    return (0);
}


-- 
           Summary: trampolines not working on x86-64 windows vista
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: charlet at gcc dot gnu dot org
  GCC host triplet: x86_64-pc-mingw32


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

Reply via email to