This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: ARM memcpy on unaligned pointers and -O2
- From: Jason R Thorpe <thorpej at wasabisystems dot com>
- To: Shaun Jackman <sjackman at pathwayconnect dot com>
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Dec 2001 09:28:37 -0800
- Subject: Re: ARM memcpy on unaligned pointers and -O2
- Organization: Wasabi Systems, Inc.
- References: <200112131024.KAA28446@cam-mail2.cambridge.arm.com> <E16EZ6W-0002Gd-00@dazed>
- Reply-to: thorpej at wasabisystems dot com
On Thu, Dec 13, 2001 at 09:53:01AM -0700, Shaun Jackman wrote:
> I recognized that afterwords and cast the arguments to memcpy()
>
> uint32
> ld32( const uint32* p)
> {
> uint32 ret;
> memcpy( &ret, (uint8*)p, sizeof( ret));
> return ret;
> }
>
> void
> str32( uint32* p, uint32 val)
> {
> memcpy( (uint8*)p, &val, sizeof( *p));
> }
>
> It seems the behaviour persists though. In fact, it has the exact same
> behaviour if I change the parameters from uint32* to void*.
This behavior matches my experience with GCC, as well. Other compilers
(such as Digital Unix's) to honor the casts in this case, but for GCC,
you have to actually do this:
char *cp = (char *) src;
memcpy(&ret, cp, sizeof(ret));
I think GCC should honor the cast, like other compilers do.
--
-- Jason R. Thorpe <thorpej@wasabisystems.com>