memcpy() bug

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: memcpy() bug

Post by bob »

Dann Corbit wrote:
Robert Pope wrote:
sje wrote:Since source and destination objects are both structs of the same type, why not use a direct assignment instead of memcpy()?

Code: Select all

pline->leaf = *bd;
Does that work? I thought you could only do that with the simple types, like int.
If you have pointers to objects in your struct, then you might have problems due to shallow copy.

Do a web search for shallow copy deep copy if you are not sure what I mean.
This simply shows that pointers, in the wrong hands, can cause problems no matter what the compiler does. I don't want a "fool-proof language". I want a high-performance language with enough flexibility that I can do what I need to do without the compiler getting in the way. One can always revert to pascal of course. Or Java.