This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 708 - placement array new doesn't work for Eigen types
Summary: placement array new doesn't work for Eigen types
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-26 19:53 UTC by scott snyder
Modified: 2019-12-04 12:50 UTC (History)
2 users (show)



Attachments
patch (700 bytes, patch)
2013-11-26 19:55 UTC, scott snyder
no flags Details | Diff

Description scott snyder 2013-11-26 19:53:57 UTC
hi -

Some of the Eigen objects define their own new/delete operators.
However, these definitions omit placement array new (but both
array new and placement new are there).

As an example, this doesn't compile (tested against eigen-5097c01bcdc4,
but from inspection of the source in the repository, this should still
be there in the latest version):

-------------
#include <Eigen/Core>

void* test(size_t sz, void* p)
{
  return new (p) Eigen::Matrix<double, 3, 1>[sz];
}
-------------


This gives a compilation error starting with 

-------------
etest.cc: In function ‘void* test(std::size_t, void*)’:
etest.cc:5:48: error: no matching function for call to ‘Eigen::Matrix<double, 3, 1>::operator new [](sizetype, void*&)’
   return new (p) Eigen::Matrix<double, 3, 1>[sz];
                                                ^
-------------

This came about trying to generate wrappers for calling Eigen objects
from python / interpreted C++ using root (http://root.cern.ch);
the automatically-generated wrapper code calls placement array new.


If i add a definition for placement array new along the lines of the
existing non-array placement new (see attached patch), then the error
goes away.

thanks,
sss
Comment 1 scott snyder 2013-11-26 19:55:00 UTC
Created attachment 401 [details]
patch
Comment 2 Gael Guennebaud 2013-11-27 09:49:18 UTC
thank you for the report. I made it static and also added the respective placement array delete:

https://bitbucket.org/eigen/eigen/commits/a44c47417c23/
Changeset:   a44c47417c23
User:        ggael
Date:        2013-11-27 09:46:59
Summary:     Fix bug 708: add placement new/delete for array

https://bitbucket.org/eigen/eigen/commits/39f422316ae8/
Changeset:   39f422316ae8
Branch:      3.2
User:        ggael
Date:        2013-11-27 09:46:59
Summary:     Fix bug 708: add placement new/delete for array
(transplanted from a44c47417c2319d737b8b99bb22dfae276a9757f)
Comment 3 Nobody 2019-12-04 12:50:31 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/708.

Note You need to log in before you can comment on or make changes to this bug.