[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Deprecated warning on 3.4.1
From: |
Dave Hylands |
Subject: |
RE: [avr-gcc-list] Deprecated warning on 3.4.1 |
Date: |
Thu, 5 Aug 2004 06:38:22 -0700 |
The
*dst++ = *src++
Is fairly traditional code used inside a copy loop. So I think that the
original intent was this:
*dst++ = *src;
src++;
So the original binding was correct.
I think that this needs to be rewritten as:
*dst = *(unsigned char *)src;
src = (whatever type src is)((unsigned char *)src + 1);
The original form was equivalent to:
(unsigned char *)src = (unsigned char *)src + 1;
Compiling this snippet (with -O)
void copy( unsigned char *dst, void *src )
{
while ( *(unsigned char *)src )
{
*dst++ = *(((unsigned char *)src)++);
}
}
Produces identical assembly output (minus the warning) to this version
(also using -O):
void copy( unsigned char *dst, void *src )
{
while ( *(unsigned char *)src )
{
*dst++ = *(unsigned char *)src;
src = (unsigned char *)src + 1;
}
}
So we can be sure that they are in fact equivalent.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
> ++ binds tighter than *, so you've done:
>
> dereference the incremented cast of src to unsigned char *
>
> (and so you are indeed using the result of a cast as an lvalue)
>
> You presumably wanted
>
> (*((unsigned char *)src))++
>
> which is
>
> increment the dereference of the cast of src to unsigned char *
>
> David Gay
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
>