An expression using ptr arithmetic yields an unusual result
unless a cast is applied;
The problematic expression;
 MaxTimings = ((EDIDDetailed *) &pExt->checksum) - pDTD;
works only when cast as;
 MaxTimings = (((uintptr_t) &pExt->checksum) - ((uintptr_t)
pDTD))/sizeof(*pDTD);

This occurs on compilers back to 3.0.3 when testing on a x86. It's also present
in a cross compiler built using 4.3.0 source
Works on a Sun/Solaris compiler.
A test program is attached


-- 
           Summary: Pointer arithmetic yields strange result
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: john dot spelis at 3dlabs dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to