Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent type used for size of containers #3085

Closed
WardBrian opened this issue Jun 17, 2024 · 0 comments · Fixed by #3086
Closed

Inconsistent type used for size of containers #3085

WardBrian opened this issue Jun 17, 2024 · 0 comments · Fixed by #3086

Comments

@WardBrian
Copy link
Member

Description

The various functions in the Math library that deal with sizes of containers return different types than each other:

  • size() returns size_t (equivalent to unsigned long int)
  • rows() returns int
  • cols() returns an Eigen::Index which at least on GCC is equivalent to long int
  • num_elements() returns int
  • dims() returns a vector of int

In particular, size_t is problematic because it is an unsized type, which leads to bad semantics when the result is used in a mathematical expression as seen in this forum post

We should probably use the same type for all of these functions. Because int is what is used in the language, that seems like a reasonable choice. If we're worried about internal overflows, we should at least used a signed type like ssize_t/long int, rather than size_t

Current Version:

v4.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant