[Bullet 2.53] Issues in btAlignedObjectArray.h

Post Reply
thebolt
Posts: 6
Joined: Tue Jun 19, 2007 9:16 am
Location: Sweden

[Bullet 2.53] Issues in btAlignedObjectArray.h

Post by thebolt » Tue Jun 19, 2007 10:59 am

Hi,

I've found two issues in btAlignedObjectArray.h in latest version (2.53)

1. Placement new is declared in header <new>, not <memory.h>.
2. reserve(int) method check capacity() < _Count twice.

The first one cause a compilation error, second one just cosmetic (and possibly two cycles or so on reserve).

-Marten Svanfeldt

User avatar
Erwin Coumans
Site Admin
Posts: 4085
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: [Bullet 2.53] Issues in btAlignedObjectArray.h

Post by Erwin Coumans » Tue Jun 19, 2007 4:37 pm

thebolt wrote: 1. Placement new is declared in header <new>, not <memory.h>.
It depends which platform and compiler.

I tried compiling it under Mac OSX/gcc, Linux gcc, and Windows Visual Studio 2005 and all work fine. Using <new> doesn't work on some of those platforms. Note we need both memcpy and placement new.

So... which platform/compiler combo is broken right now?
Thanks,
Erwin

thebolt
Posts: 6
Joined: Tue Jun 19, 2007 9:16 am
Location: Sweden

Re: [Bullet 2.53] Issues in btAlignedObjectArray.h

Post by thebolt » Tue Jun 19, 2007 10:07 pm

Erwin Coumans wrote: It depends which platform and compiler.

I tried compiling it under Mac OSX/gcc, Linux gcc, and Windows Visual Studio 2005 and all work fine. Using <new> doesn't work on some of those platforms. Note we need both memcpy and placement new.

So... which platform/compiler combo is broken right now?
Thanks,
Erwin
Well, standard conformant ones should have it in <new> (thats what ISO 14882/2003 says at least,) But ok.. might need both then.

The compiler I used that hit the problem was VC 2005 (for Xenon), however I did a small test here to work out what actually is needed and it seems like this:

VC 2005 (both win32 and xenon) needs <new> for placement new and <memory.h> for memcpy. That placement new works without <new> on win32 seems to be due to it getting included indirectly somewhere in bullet. This is also what the documentation states

The code I used for testing was a completely empty cpp file containing only

Code: Select all

void a()
{
  void *b = 0;
  int *i = new (b) int;
}

User avatar
Erwin Coumans
Site Admin
Posts: 4085
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans » Tue Jun 19, 2007 11:51 pm

Ok, we will stick with #include <new> for placement new

However, some platforms define memcpy in <memory.h> others in <string.h>, so this feature will be disabled by default.
This is used when swapping elements in the array. Instead of memcpy, the former assignment operator is used. This should be taken into account when using the array.

It has been checked into Subversion, should go into next release, see updated source here.


Thanks for the feedback,
Erwin

Post Reply