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]

Re: [Bug c/37609] New: Pointer arithmetic yields strange result




Sent from my iPhone

On Sep 21, 2008, at 9:00 AM, "john dot spelis at 3dlabs dot com" <gcc-bugzilla@gcc.gnu.org > wrote:

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

That is a signed division while the below is unsigned.



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




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