On 18/12/12 18:10, Radu Rendec wrote: > On Tue, 2012-12-18 at 10:29 -0600, Peter Bigot wrote: > >> Yes, it's obviously sign-extending the pointers and doing a 32-bit >> subtraction. I have a recollection that how mspgcc treated pointers >> (signed/unsigned) changed sometime during the 4.7 development cycle. >> >> mspgcc-20120911 appears to do the right thing and generates a simple >> 16-bit subtract. > > Hi Peter, > > Thanks for the fast answer! Casting the pointers to "unsigned int" > before subtracting seems to be a valid workaround to the problem.
Casting both the pointers to "unsigned int" before the arithmetic, then to "int *" afterwards, should work in this case. But be careful of doing that in general with pointer arithmetic - if the pointers are to something bigger than "char", then the result would not be valid as pointer subtraction returns the number of pointed-to elements between the pointers, not the number of bytes. > > Is there any chance of getting the right behaviour in 20120406, since > it's supposed to be "LTS" ? > > Thanks, > > Radu > > ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users