Skip to content

fix the remaining warnings in the codebase #123

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

Closed

Conversation

superwhiskers
Copy link
Collaborator

this pull request fixes the remaining warnings resulting from the addition of -Wall -Wextra -Wconversion -Wpedantic to the default cxxflags. these were missed in the initial pull request due to the source files they're in being gated behind the GRIDKIT_ENABLE_IPOPT define.

this pull request also removes some unnecessary commented out flags in the root CMakeLists.txt file due to them being superseded by the default flag list and also being covered by the RelWithDebInfo and Debug CMAKE_BUILD_TYPE values (iirc).

@superwhiskers superwhiskers requested a review from pelesh June 2, 2025 14:44
@superwhiskers superwhiskers marked this pull request as draft June 2, 2025 14:51
@superwhiskers
Copy link
Collaborator Author

managed to unearth some more warnings, fixing those first

@superwhiskers superwhiskers marked this pull request as ready for review June 2, 2025 20:50
@superwhiskers
Copy link
Collaborator Author

this should cover all of them. all tests pass. no warnings are shown anymore

Comment on lines +47 to +49
y_.resize(static_cast<size_t>(size_));
yp_.resize(static_cast<size_t>(size_));
f_.resize(static_cast<size_t>(size_));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it a little less cluttered. Consider something like this here and in similar places throughout the code.

Suggested change
y_.resize(static_cast<size_t>(size_));
yp_.resize(static_cast<size_t>(size_));
f_.resize(static_cast<size_t>(size_));
auto size = static_cast<size_t>(size_);
y_.resize(size);
yp_.resize(size);
f_.resize(size);

@@ -37,7 +37,7 @@ int main(int /* argc */, char const** /* argv */)
// input
induct->setExternalConnectionNodes(0, 1);
// output
induct->setExternalConnectionNodes(1, -1);
induct->setExternalConnectionNodes(1, static_cast<size_t>(-1));
Copy link
Collaborator

@nkoukpaizan nkoukpaizan Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this conversion meaningful? This will store the largest integer, right? It works because the same casting is done for the variable this is compared to, e.g.,

if (component->getNodeConnection(j) != neg1_)

static constexpr IdxT neg1_ = static_cast<IdxT>(-1);

but I don't think it is the intended conceptual purpose of using -1.
@reid-g should chime in here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should just store the largest integer size_t can hold. i went with this as i wasn't totally sure how invasive we should be here (same applies to the other comments). i would much rather

  • either set it to the maximum size_t
  • or adjust the api to provide another way to communicate the same intent (std::optional or something)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay as is. The index -1 stands for the ground node. It only needs to be a very distinctive integer.

CC @reid-g

@superwhiskers
Copy link
Collaborator Author

moved to #125

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 this pull request may close these issues.

4 participants