Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: memcpy vs. gcc strict aliasing

>All problems I have seen in this area where (at least) "dubious" casts of
>the source pointer and always very simple to fix. AFAIR this behaviour
>(treating builtin memcpy just as a structure assignment) is backed by
>the standard. Don't use a "struct foo" pointer when the thing it points
>to is not a struct foo (but only it's bytewise copy in an input stream).
>Just memcpy with the char pointer as source and a real struct foo as the
>target, and everything is fine.

FWIW, the original problem that prompted this thread was clearly not a case
of casting a random network buffer to a pointer to struct foo.  It was
a struct foo to a struct foo.  I can believe that maybe the allocator that
lint uses isn't aligning things properly (although it seems to try to), and
that might be causing the problem.

(A side note - does it make sense to have lint use it's own allocator?  Could
it not simply use malloc()?  Are the memory demands by lint that large?)


Home | Main Index | Thread Index | Old Index