------- Comment #4 from pinskia at gcc dot gnu dot org 2007-03-21 01:40 ------- (In reply to comment #3) > Can you point me to a description of the C++ aliasing rules?
You can find some of it on http://gcc.gnu.org/bugs.html under the non bug section. There are a lot more pages on then I can think of. > Is the memcpy() workaround specific to GCC, or is memcpy > part of the standard with special rules regarding aliasing? > (I ask because our code base has to work on a half-dozen > platforms, many of which don't use GCC). It is part of the standard. > Will GCC optimize the memcpy() and intermediate variable ("n") away? > With gcc323 this code comes out to about 6 instructions, so even 1 or 2 > more would be a large percentage hit... Later versions should optimize it correctly. Why do you think 1 or 2 more instructions will be a hit, most of the problems you are going to hit into now is cache issues anyways unless you do a better malloc pool in the first case as you will have non consecative memory that would really like to be close together. Also you alloc the memory and then you add it to your free list but never actually free the memory so say if you alloc 100 10 sized objects and free those, and then alloc 50 20 sized objects, now your memory usage is twice than what it should be. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31289