This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/37609] Pointer arithmetic yields strange result
- From: "pinskia at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Sep 2008 16:36:20 -0000
- Subject: [Bug target/37609] Pointer arithmetic yields strange result
- References: <bug-37609-8983@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from pinskia at gmail dot com 2008-09-21 16:36 -------
Subject: Re: 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
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37609