New user self-registration is disabled due to spam. Please email eigen-core-team @ if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 1432 - Bypass memcpy for unsuitable scalar types (aka make a better use of C++11 type-traits)
Summary: Bypass memcpy for unsuitable scalar types (aka make a better use of C++11 typ...
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Crash
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2017-06-06 08:49 UTC by Gael Guennebaud
Modified: 2018-07-18 21:35 UTC (History)
3 users (show)


Description Gael Guennebaud 2017-06-06 08:49:33 UTC

basically some types like std::string might not be copiable by memcpy if too short. The proposed fix is to use c++11 type-traits to detect this and bypass memcpy (in Memory.h) in such cases. In c++98, we would document it a known pitfall.

In the same vein, NumTraits::RequireInitialization currently default to:

RequireInitialization = internal::is_arithmetic<T>::value ? 0 : 1

whereas c++11 provides more accurate type-traits for that.
Comment 1 Gael Guennebaud 2017-06-06 08:50:24 UTC
oops, the missing link is:
Comment 2 Gael Guennebaud 2018-07-18 21:35:33 UTC
Summary:     Bug 1432: fix conservativeResize for non-relocatable scalar types. For those we need to by-pass realloc routines and fall-back to allocate as new - copy - delete. The remaining problem is that we don't have any mechanism to accurately determine whether a type is relocatable or not, so currently let's be super conservative using either RequireInitialization or std::is_trivially_copyable

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