Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Jun 19, 2007 10:59 am 
Offline

Joined: Tue Jun 19, 2007 9:16 am
Posts: 6
Location: Sweden
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


Top
 Profile  
 
PostPosted: Tue Jun 19, 2007 4:37 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3998
Location: California, USA
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


Top
 Profile  
 
PostPosted: Tue Jun 19, 2007 10:07 pm 
Offline

Joined: Tue Jun 19, 2007 9:16 am
Posts: 6
Location: Sweden
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:
void a()
{
  void *b = 0;
  int *i = new (b) int;
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 19, 2007 11:51 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3998
Location: California, USA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group