The included program coredumps during execution when compiled with -O2 but not
when compiled with -O0.  The problem appears to be with combine and the use of
the ptr_extend_plus_2 instruction.  GCC is losing track of what is and isn't a
pointer.  I am not entirely sure if the program is legal given all the casts.

struct magic_state {
    void *mgs_sv;
};
typedef struct magic_state MGS;

MGS *PL_savestack;

void
restore_magic(void *p)
{
    MGS* mgs = ((MGS*) ((char*)PL_savestack + (long)(p)));

    if (!mgs->mgs_sv)
        return;
    mgs->mgs_sv = ((void *)0);
}

MGS s;

main()
{
        PL_savestack = &s;
        restore_magic((void *) 0);
}

-- 
           Summary: ia64-hp-hpux11.23
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sje at cup dot hp dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: ia64-hp-hpux11.23
GCC target triplet: ia64-hp-hpux11.23


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

Reply via email to