Skip to content

Fix warnings and set them to be errors#242

Open
garlic-hub wants to merge 1 commit into
usnistgov:masterfrom
garlic-hub:warnings_fix
Open

Fix warnings and set them to be errors#242
garlic-hub wants to merge 1 commit into
usnistgov:masterfrom
garlic-hub:warnings_fix

Conversation

@garlic-hub

@garlic-hub garlic-hub commented Jun 19, 2025

Copy link
Copy Markdown

Fixes Wall and Wextra warnings emitted from gcc 13.3. Also enables Werror to prevent new warnings in the future. Attempted to test with clang as well, but my distro doesn't seem to build it with OMP support enabled.

Comment thread cpp/restart_main.cpp

returnIndex = ((size_t) floor((1.0 - alpha) * ((double) simulation_rounds))) - 1;
assert((returnIndex >= 0) && (returnIndex < simulation_rounds));
assert(returnIndex < simulation_rounds);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Bonus of fixing the signed unsigned comparison on this line is that >= 0 is not required anymore since unsigned values can't be negative

@celic

celic commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Any reason to introduce sstream when printf is used everywhere else?

@garlic-hub

garlic-hub commented May 28, 2026

Copy link
Copy Markdown
Author

Any reason to introduce sstream when printf is used everywhere else?

If you mean instead of using snprintf, sstream simplifies not needing to manage a local buffer. testRun->errorMsg is a std::string anyway, so the heap is being allocated no matter what. ss.str() is an rvalue, so it should use the move constructor to avoid copy overhead.

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.

2 participants