Closed GoogleCodeExporter closed 8 years ago
I forgot the const for the parameter of the operator.
Original comment by tissen.p...@googlemail.com
on 8 Nov 2011 at 2:08
Attachments:
It is best to avoid any deep copying of arrays.
I rather add some assert instead (to avoid accidentally copying all that data)
Can you create collision shapes on the heap, instead of on the stack?
Thanks!
Erwin
Original comment by erwin.coumans
on 11 Nov 2011 at 12:55
[deleted comment]
An assert is fine. It's just that in the current state there's no warning that
copying is dangerous.
Would you just put the assert only in the assignment operator or the copy
constructor as well?
btAlignedObjectArray<T> arr;
arr = btAlignedObjectArray<T>(); //A) uses the = operator
btAlignedObjectArray<T> arr2 = arr; //B) uses the copy constructor
arr = arr2 //C) uses the = operator
btAlignedObjectArray<T> arr3 = btAlignedObjectArray<T>(); //D) uses the copy
constructor
So would you want to discourage only A) and C) or B) and D) as well? All of
them present the problem ob doubly freeing the memory
Original comment by tissen.p...@googlemail.com
on 11 Nov 2011 at 4:55
also, wouldn't additionally making the copy constructor and the = operator
private also create compile time errors, so that it just won't compile if
someone tries to copy it?
Original comment by tissen.p...@googlemail.com
on 11 Nov 2011 at 5:18
The issue is fixed in latest trunk:
http://code.google.com/p/bullet/source/detail?r=2456
If too many Bullet users have issues with this, I'll enable the
BT_ALLOW_ARRAY_COPY_OPERATOR by default.
Original comment by erwin.coumans
on 15 Nov 2011 at 8:10
Original issue reported on code.google.com by
tissen.p...@googlemail.com
on 8 Nov 2011 at 1:36Attachments: