This bugzilla service is closed. All entries have been migrated to
Bug 898 - const_cast_ptr is not inlined on MSVC 2013
Summary: const_cast_ptr is not inlined on MSVC 2013
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.2
Hardware: x86 - general Windows
: Normal Performance Problem
Assignee: Nobody
Depends on:
Reported: 2014-10-21 17:49 UTC by Emily
Modified: 2019-12-04 13:51 UTC (History)
3 users (show)


Description Emily 2014-10-21 17:49:00 UTC
Visual Studio has a thing where it will some times refuse to inline even the most obvious functions unless you specify that is should, by using the `inline` keyword.

In an optimized build I get non-inlined calls to:


template<typename T>
T* const_cast_ptr(const T* ptr)
  return const_cast<T*>(ptr);

Related ASM:
--- d:\work\include\eigen\src\core\util\xprhelper.h --------------------
 mov         rax,rcx

 lea         rcx,[rax+rcx*8]  
 call        Eigen::internal::const_cast_ptr<double> (013F4C8215h)  
 mov         r14,qword ptr [r14+8]

I propose to add the `inline` keyword to const_cast_ptr to make MSVC inline it. I have done it locally and it has the intended effect.
Comment 1 Christoph Hertzberg 2014-10-28 14:53:45 UTC
That change appears harmless enough. Pushed to default and 3.2 branches:
Comment 2 Nobody 2019-12-04 13:51:44 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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:

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