memcpy / Language Lawyer / optimization question

Steve Ellcey sje@cup.hp.com
Fri Dec 10 16:51:00 GMT 2004


> From: "Joseph S. Myers" <joseph@codesourcery.com>
>
> The casts in the calls to memcpy are irrelevant: the undefined behavior 
> occurs before them, at the point where you cast an unaligned pointer to 
> int *.

Thanks to everyone for the info on memcpy.  I think I have the right fix
for the Fortran library.  There is a routine that returns a 'char *' and
that return value was being cast to 'int *' and put into an 'int *'
variable before being passed into memcpy.

If I remove the cast and make the variable a 'char *' then I don't need
any casts in the memcpy call and everything works correctly.

It does looks like 'void *' should have been behaving just like 'char *'
so I will look into that issue some more and either come up with a patch
or submit a PR for the problem.

Steve Ellcey
sje@cup.hp.com



More information about the Gcc mailing list