This bugzilla service is closed. All entries have been migrated to
Bug 508 - Stack overflow with sqrt of an expression which returns a double (a 1x1 return type)
Summary: Stack overflow with sqrt of an expression which returns a double (a 1x1 retur...
Status: RESOLVED DUPLICATE of bug 314
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - expression templates (show other bugs)
Version: 3.1
Hardware: All Windows
: Normal minor
Assignee: Nobody
Depends on:
Blocks: 3.2
  Show dependency treegraph
Reported: 2012-09-05 03:58 UTC by Tom
Modified: 2019-12-04 11:52 UTC (History)
3 users (show)


Description Tom 2012-09-05 03:58:16 UTC
int main(int argc, char* argv[])
    Eigen::Vector2d v(1.0,2.0);
    double d = sqrt(v.transpose() * v);

This triggers an infinite recursion/stack overflow when sqrt and sqrt_default_impl call each other.

Easy to work around--e.g. sqrt(;

Copied from the call stack:

>	Eigen::internal::sqrt_default_impl<Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3>,0>::run(const Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> & x)  Line 417 + 0xa bytes	C++

 	Eigen::internal::sqrt<Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> >(const Eigen::GeneralProduct<Eigen::Transpose<Eigen::Matrix<double,2,1,0,2,1> >,Eigen::Matrix<double,2,1,0,2,1>,3> & x)  Line 447 + 0xf bytes	C++
Comment 1 Jitse Niesen 2012-09-05 18:41:47 UTC
I've no time at the moment to investigate, but this is probably the same issue as bug 314. However, it is more urgent to fix now that it's more than a theoretical problem.
Comment 2 Gael Guennebaud 2012-10-09 13:49:26 UTC
That's indeed the same issue.

*** This bug has been marked as a duplicate of bug 314 ***
Comment 3 Nobody 2019-12-04 11:52:30 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.