Skip to content

Unsigned integer checked for negative values in Solution.h #1849

@g3bk47

Description

@g3bk47

Problem description

In the following snippet

string adjacentName(size_t i) const {
if (i < 0 || i >= m_adjacent.size()) {
throw CanteraError("Solution::adjacentName", "Invalid index {}.", i);
the function argument i is unsigned, but i < 0 is checked. This currently generates a warning (at least with gcc 14). I think most often, indices in Cantera are defined as size_t, so the check should be superfluous. But if this is called in other language interfaces, an error message with a signed index might be more helpful to the user (if e.g. -1 is passed). What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions