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

Cleanup compiler warnings: unused variables/typedefs, uninitialised vars, etc. #2933

Merged
merged 9 commits into from
Aug 29, 2023

Conversation

andrjohns
Copy link
Collaborator

Summary

Cleans up the following compiler warnings:

  • Uninitalised variables
  • Unused variables
  • Unused typedefs
  • Inconsistent class/struct typing
  • Constructor initialiser ordering

Tests

No new tests, existing tests should pass

Side Effects

N/A

Release notes

Cleans up several compiler warnings throughout Math library and tests

Checklist

  • Math issue #(issue number)

  • Copyright holder: Andrew Johnson

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

stan/math/opencl/rev/matrix_power.hpp Show resolved Hide resolved
stan/math/prim/fun/lb_free.hpp Show resolved Hide resolved
stan/math/prim/prob/gaussian_dlm_obs_rng.hpp Show resolved Hide resolved
test/unit/math/prim/core/init_threadpool_tbb_test.cpp Outdated Show resolved Hide resolved
@@ -23,7 +23,7 @@ namespace math {
* <p>This function does not recover any memory from the computation.
*
*/
static void grad() {
static inline void grad() {
Copy link
Member

Choose a reason for hiding this comment

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

This and the similar change in set_zero_all_adjoints_nested seem like they're different from the rest of the changes here - why do these functions become inline?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Static functions that aren't used in a given translation unit give an 'unused-function' warning, but this is suppressed if the static function is declared inline: https://sourceware.org/legacy-ml/gdb/2015-02/msg00064.html

These are small enough functions that I think inlining is fine imo

@WardBrian
Copy link
Member

The latest set of changes seem good to me, I'd appreciate someone like @SteveBronder or @syclik giving it a once over before merging to make sure I'm not missing anything

Copy link
Collaborator

@SteveBronder SteveBronder left a comment

Choose a reason for hiding this comment

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

lgtm!

@WardBrian WardBrian merged commit bdf281f into develop Aug 29, 2023
7 checks passed
@WardBrian WardBrian deleted the compiler-warnings branch August 29, 2023 15:17
@syclik
Copy link
Member

syclik commented Sep 6, 2023

@andrjohns THANK YOU!!!

@WardBrian, thanks for reviewing!

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.

5 participants