This bugzilla service is closed. All entries have been migrated to
Bug 626 - No range check for sparse matrix
Summary: No range check for sparse matrix
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
: 641 (view as bug list)
Depends on:
Blocks: 3.2
  Show dependency treegraph
Reported: 2013-06-28 13:19 UTC by Kolja Brix
Modified: 2019-12-04 12:27 UTC (History)
3 users (show)

Test for sparse matrix range check (1016 bytes, text/x-c++src)
2013-06-28 13:19 UTC, Kolja Brix
no flags Details

Description Kolja Brix 2013-06-28 13:19:25 UTC
Created attachment 361 [details]
Test for sparse matrix range check

There is no range check for sparse matrices:

For a standard SparseMatrix<double, Dynamic> (row major format?), elements above the upper column limit can be inserted, e.g. an element in column 11 in a 10 x 10 sparse matrix. There is no error or exception thrown.

Inserting an entry above the row limit usually leads to a segmentation fault.

Both behaviors are demonstrated in the example code attached.
Comment 1 Christoph Hertzberg 2013-06-28 13:36:42 UTC
Indeed, this is not checked.
Another thing: Dynamic should not be a allowed as template parameter. Sparse matrices are always dynamic sized. 
Only valid options at the moment are ColMajor (default) and RowMajor.
Comment 2 Gael Guennebaud 2013-06-28 16:16:56 UTC
Both fixed for both matrices and vectors:
Changeset:   d3495e9a1994
User:        ggael
Date:        2013-06-28 15:56:43
Summary:     Bug 626: add compiletime check of the Options template parameter of SparseMatrix and SparseVector. Fix eval and plain_object for sparse objects.
Changeset:   9998c8a1b9c0
User:        ggael
Date:        2013-06-28 16:16:02
Summary:     Fix bug 626: add assertion on input ranges for coeff* and insert members for sparse objects
Comment 3 Alexander Werner 2013-08-08 09:06:43 UTC
*** Bug 641 has been marked as a duplicate of this bug. ***
Comment 4 Nobody 2019-12-04 12:27:36 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.