Why all that whenOriginally Posted by Yasir_Malik
does the same thing without worrying about the shape of the structure? But as mentioned by someone else, memcpy is the way to go because of possible alignment issues.Code:a = *(A*)buf;
Why all that whenOriginally Posted by Yasir_Malik
does the same thing without worrying about the shape of the structure? But as mentioned by someone else, memcpy is the way to go because of possible alignment issues.Code:a = *(A*)buf;
probably depending on compiler implementation, your suggestion is probably implemented as memcpy() anyway.Originally Posted by codie
I wrote a tiny test program with VC++ 2005 Pro did a release build, and had it produce an assembly listing. It looks like does not do any copying at all, just replaces a pointer to the struct object with a pointer to buf.
> It looks like does not do any copying at all, just replaces a pointer to the struct object with a pointer to buf
Yes, beware of optimisers being extremely effective in working out what really small programs do.
It probably decided that buff was never used after the assignment, so the easy thing to do was just re-use buff for it's new purpose.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Well back in the days of 8080 we would lose precious cycles for the rep prefix so prefixes had to be watched in general, but that's obviously no longer a problem.
Neither can a normal move, but with mmx your working with x86 quadwords instead of double words.MMX cannot copy from memory to memory so I don't see how this would speed anything up.