-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
managed to unearth some more warnings, fixing those first |
this should cover all of them. all tests pass. no warnings are shown anymore |
y_.resize(static_cast<size_t>(size_)); | ||
yp_.resize(static_cast<size_t>(size_)); | ||
f_.resize(static_cast<size_t>(size_)); |
There was a problem hiding this comment.
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.
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)); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
moved to #125 |
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 theGRIDKIT_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 theRelWithDebInfo
andDebug
CMAKE_BUILD_TYPE
values (iirc).