Skip to content

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

Merged
WardBrian merged 9 commits intodevelopfrom
compiler-warnings
Aug 29, 2023
Merged

Cleanup compiler warnings: unused variables/typedefs, uninitialised vars, etc.#2933
WardBrian merged 9 commits intodevelopfrom
compiler-warnings

Conversation

@andrjohns
Copy link
Copy Markdown
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

Comment thread stan/math/opencl/rev/matrix_power.hpp
Comment thread stan/math/prim/fun/lb_free.hpp
Comment thread stan/math/prim/prob/gaussian_dlm_obs_rng.hpp
Comment thread test/unit/math/prim/core/init_threadpool_tbb_test.cpp
*
*/
static void grad() {
static inline void grad() {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@WardBrian WardBrian deleted the compiler-warnings branch August 29, 2023 15:17
@syclik
Copy link
Copy Markdown
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