Giter Site home page Giter Site logo

Comments (8)

nilsdeppe avatar nilsdeppe commented on September 6, 2024

Here is an updated list of issues:

@wthrowe

/home/nils/SpECTRE/spectre/src/Time/Slab.hpp:91:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;
                    ^
/home/nils/SpECTRE/spectre/src/Time/Time.hpp:57:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;
                    ^
/home/nils/SpECTRE/spectre/src/Time/Time.hpp:112:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;

/home/nils/SpECTRE/spectre/src/Time/TimeSteppers/AdamsBashforthN.cpp:141:18: warning: initialization of 'coefficients_' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
AdamsBashforthN::coefficients_{{
                 ^
/usr/bin/../include/c++/v1/vector:530:5: note: possibly throwing constructor declared here
    vector(initializer_list<value_type> __il);
    ^
/home/nils/SpECTRE/spectre/src/Time/TimeSteppers/AdamsBashforthN.cpp:141:18: warning: redundant 'coefficients_' declaration [readability-redundant-declaration]
AdamsBashforthN::coefficients_{{
                 ^
/home/nils/SpECTRE/spectre/src/Time/TimeSteppers/AdamsBashforthN.hpp:91:63: note: previously declared here
  static const std::array<std::vector<double>, maximum_order> coefficients_;
                                                              ^

/home/nils/SpECTRE/spectre/tests/Unit/Time/TimeSteppers/TimeStepperTestUtils.hpp:18:11: warning: non-const reference parameter 'time', make it const or use a pointer [google-runtime-references]
    Time& time,
          ^
/home/nils/SpECTRE/spectre/tests/Unit/Time/TimeSteppers/TimeStepperTestUtils.hpp:19:13: warning: non-const reference parameter 'y', make it const or use a pointer [google-runtime-references]
    double& y,
            ^
/home/nils/SpECTRE/spectre/tests/Unit/Time/TimeSteppers/TimeStepperTestUtils.hpp:20:51: warning: non-const reference parameter 'history', make it const or use a pointer [google-runtime-references]
    std::deque<std::tuple<Time, double, double>>& history,
                                                  ^
/home/nils/SpECTRE/spectre/tests/Unit/Time/TimeSteppers/TimeStepperTestUtils.hpp:40:51: warning: non-const reference parameter 'history', make it const or use a pointer [google-runtime-references]
    std::deque<std::tuple<Time, double, double>>& history,
                                                  ^

/home/nils/SpECTRE/spectre/src/Time/Slab.hpp:91:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;
                    ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:30:5: warning: do not use 'else' after 'return' [readability-else-after-return]
  } else if (is_at_slab_start()) {
    ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:33:7: warning: do not use 'else' after 'return' [readability-else-after-return]
    } else {
      ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:44:7: warning: do not use 'else' after 'return' [readability-else-after-return]
    } else {
      ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:57:5: warning: do not use 'else' after 'return' [readability-else-after-return]
  } else {
    ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:65:5: warning: do not use 'else' after 'return' [readability-else-after-return]
  } else {
    ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:84:5: warning: do not use 'else' after 'return' [readability-else-after-return]
  } else if (a.slab().is_followed_by(b.slab())) {
    ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:87:7: warning: do not use 'else' after 'return' [readability-else-after-return]
    } else {
      ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:97:7: warning: do not use 'else' after 'return' [readability-else-after-return]
    } else {
      ^
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:143:5: warning: do not use 'else' after 'return' [readability-else-after-return]
  } else {
    ^
/home/nils/SpECTRE/spectre/src/Time/Time.hpp:57:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;
                    ^
/home/nils/SpECTRE/spectre/src/Time/Time.hpp:112:21: warning: non-const reference parameter 'p', make it const or use a pointer [google-runtime-references]
  void pup(PUP::er& p) noexcept;
                    ^

@osheamonn

/home/nils/SpECTRE/spectre/tests/Unit/ErrorHandling/Test_FloatingPointExceptions.cpp:17:10: warning: Value stored to 'invalid' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
  double invalid = sqrt(x);
         ^
/home/nils/SpECTRE/spectre/tests/Unit/ErrorHandling/Test_FloatingPointExceptions.cpp:17:10: note: Value stored to 'invalid' during its initialization is never read
  double invalid = sqrt(x);
         ^
/home/nils/SpECTRE/spectre/tests/Unit/ErrorHandling/Test_FloatingPointExceptions.cpp:46:10: warning: Value stored to 'invalid' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
  double invalid = sqrt(x);
         ^
/home/nils/SpECTRE/spectre/tests/Unit/ErrorHandling/Test_FloatingPointExceptions.cpp:46:10: note: Value stored to 'invalid' during its initialization is never read
  double invalid = sqrt(x);
         ^

@gsb76

/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:15:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (mapped_directions_[j].dimension() != j or
        ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:16:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        mapped_directions_[j].side() != Side::Upper) {
        ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:27:5: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    mapped_directions_[directions_in_host[j].dimension()] =
    ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:27:24: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    mapped_directions_[directions_in_host[j].dimension()] =
                       ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:28:10: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        (directions_in_host[j].side() == Side::Upper
         ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:29:16: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
             ? directions_in_neighbor[j]
               ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:30:16: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
             : directions_in_neighbor[j].opposite());
               ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:31:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (directions_in_host[j] != directions_in_neighbor[j]) {
        ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:31:34: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (directions_in_host[j] != directions_in_neighbor[j]) {
                                 ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:42:5: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    result[mapped_directions_[d].dimension()] =
    ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:42:12: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    result[mapped_directions_[d].dimension()] =
           ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:43:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        mapped_directions_[d].side() == Side::Upper
        ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:44:15: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
            ? segmentIds[d]
              ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.cpp:45:15: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
            : segmentIds[d].id_if_flipped();
              ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.hpp:45:12: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    return mapped_directions_[dim].dimension();
           ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.hpp:51:18: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
               ? mapped_directions_[direction.dimension()]
                 ^
/home/nils/SpECTRE/spectre/src/Domain/Orientation.hpp:52:18: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
               : mapped_directions_[direction.dimension()].opposite();
                 ^
/home/nils/SpECTRE/spectre/src/Domain/Neighbors.hpp:55:8: warning: function 'Neighbors::add_ids' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
  void add_ids(const std::unordered_set<ElementId<VolumeDim>>& additional_ids);
       ^
                                                               additional_Ids
/home/nils/SpECTRE/spectre/src/Domain/Neighbors.cpp:19:28: note: the definition seen here
void Neighbors<VolumeDim>::add_ids(
                           ^
/home/nils/SpECTRE/spectre/src/Domain/Neighbors.hpp:55:8: note: differing parameters are named here: ('additional_ids'), in definition: ('additional_Ids')
  void add_ids(const std::unordered_set<ElementId<VolumeDim>>& additional_ids);
       ^

I'll post any remaining ones once we have this batch done. (I didn't bother with ones that are my responsibility, I'll just take care of them)

from spectre.

wthrowe avatar wthrowe commented on September 6, 2024

warning: do not use 'else' after 'return' [readability-else-after-return]

I don't like this rule. I think it makes the code ugly by preventing code that does similar things from looking similar. For example, this looks like a tree of decisions, with all the branches accessible in similar ways:

if (a) {
  if (b) {
    return ...;
  } else {
    return ...;
  }
} else {
  if (c) {
    return ...;
  } else {
    return ...;
  }
}

But it takes examination to see that this is:

if (a) {
  if (b) {
    return ...;
  }
  return ...;
}
if (c) {
  return ...;
}
return ...;

(The version of this rule that I do like would be that an else block must end with a statement that does not allow the next statement to be executed (such as return, or a noreturn function call) if and only if the "then" block does.)

from spectre.

nilsdeppe avatar nilsdeppe commented on September 6, 2024

I do not have a preference, but I was able to find the origin of the warning here. Their reasoning is "The idea is to reduce indentation and the amount of code you have to keep track of when reading the code." and in the example they give, I agree, but in a decision tree I don't have a preference. I'm okay disabling this check. @kidder ?

from spectre.

kidder avatar kidder commented on September 6, 2024

I agree with Will for our use case, so let's disable the check

from spectre.

wthrowe avatar wthrowe commented on September 6, 2024

Cool. I'll disable that when I fix the other clang-tidy warnings.

from spectre.

wthrowe avatar wthrowe commented on September 6, 2024

Something to watch out for: clang-tidy does not catch non-const reference arguments when the referenced type is a template parameter or similar. We'll have to catch those ourselves.

https://bugs.llvm.org/show_bug.cgi?id=32683

from spectre.

nilsdeppe avatar nilsdeppe commented on September 6, 2024

@wthrowe new ones in clang-tidy 5:

spectre/src/Time/Slab.hpp:42:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return Slab(start, start + duration);
           ^~~~~~~~~~                  ~~
           {                           }
spectre/src/Time/Slab.hpp:48:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return Slab(end - duration, end);
           ^~~~~~~~                ~~
           {                       }
spectre/src/Time/Slab.hpp:57:42: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  Slab advance() const noexcept { return Slab(end_, end_ + (end_ - start_)); }
                                         ^~~~~~~~~                        ~~
                                         {                                }
spectre/src/Time/Slab.hpp:62:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return Slab(start_ - (end_ - start_), start_);
           ^~~~~~~~~~~                          ~~
           {                                    }
spectre/src/Time/Slab.hpp:72:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return Slab(start_, start_ + duration);
           ^~~~~~~~~~~                   ~~
           {                             }
spectre/src/Time/Slab.hpp:78:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return Slab(end_ - duration, end_);
           ^~~~~~~~~                 ~~
           {                         }
spectre/src/Time/Time.hpp:91:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return TimeDelta(new_slab, fraction());
           ^~~~~~~~~~~~~~~~~~            ~~
           {                             }
spectre/src/Time/Time.hpp:257:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  return TimeDelta(slab_, -fraction_);
         ^~~~~~~~~~~~~~~            ~~
         {                          }



spectre/tests/Unit/Options/Test_Options.cpp:284:9: warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
  CHECK(opts.get<Map>() == (std::map<std::string, int>{}));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        opts.get<Map>().empty()
/home/nils/Research/spack/opt/spack/linux-antergosrolling-x86_64/gcc-7.1.1/catch-1.9.4-qgdxfjhwk4mqhelhn2ggxmvyxvx6xm3k/include/catch.hpp:11436:98: note: expanded from macro 'CHECK'
#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
                                                                                                 ^
/home/nils/Research/spack/opt/spack/linux-antergosrolling-x86_64/gcc-7.1.1/catch-1.9.4-qgdxfjhwk4mqhelhn2ggxmvyxvx6xm3k/include/catch.hpp:2201:60: note: expanded from macro 'INTERNAL_CATCH_TEST'
    } while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
                                                           ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/stl_map.h:457:7: note: method 'map<std::__cxx11::basic_string<char>, int, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> > >'::empty() defined here
      empty() const _GLIBCXX_NOEXCEPT
      ^
spectre/tests/Unit/Options/Test_Options.cpp:426:9: warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object [readability-container-size-empty]
  CHECK(get_output(OptionContext{}) == "");
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        get_output(OptionContext{}).empty()
/home/nils/Research/spack/opt/spack/linux-antergosrolling-x86_64/gcc-7.1.1/catch-1.9.4-qgdxfjhwk4mqhelhn2ggxmvyxvx6xm3k/include/catch.hpp:11436:98: note: expanded from macro 'CHECK'
#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr )
                                                                                                 ^
/home/nils/Research/spack/opt/spack/linux-antergosrolling-x86_64/gcc-7.1.1/catch-1.9.4-qgdxfjhwk4mqhelhn2ggxmvyxvx6xm3k/include/catch.hpp:2201:60: note: expanded from macro 'INTERNAL_CATCH_TEST'
    } while( Catch::isTrue( false && static_cast<bool>( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
                                                           ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/basic_string.h:985:7: note: method 'basic_string<char, std::char_traits<char>, std::allocator<char> >'::empty() defined here
      empty() const _GLIBCXX_NOEXCEPT
      ^

@gsb76

spectre/src/Domain/Orientation.cpp:15:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (mapped_directions_[j].dimension() != j or
        ^
spectre/src/Domain/Orientation.cpp:16:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        mapped_directions_[j].side() != Side::Upper) {
        ^
spectre/src/Domain/Orientation.cpp:27:5: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    mapped_directions_[directions_in_host[j].dimension()] =
    ^
spectre/src/Domain/Orientation.cpp:27:24: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    mapped_directions_[directions_in_host[j].dimension()] =
                       ^
spectre/src/Domain/Orientation.cpp:28:10: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        (directions_in_host[j].side() == Side::Upper
         ^
spectre/src/Domain/Orientation.cpp:29:16: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
             ? directions_in_neighbor[j]
               ^
spectre/src/Domain/Orientation.cpp:30:16: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
             : directions_in_neighbor[j].opposite());
               ^
spectre/src/Domain/Orientation.cpp:31:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (directions_in_host[j] != directions_in_neighbor[j]) {
        ^
spectre/src/Domain/Orientation.cpp:31:34: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    if (directions_in_host[j] != directions_in_neighbor[j]) {
                                 ^
spectre/src/Domain/Orientation.cpp:42:5: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    result[mapped_directions_[d].dimension()] =
    ^
spectre/src/Domain/Orientation.cpp:42:12: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    result[mapped_directions_[d].dimension()] =
           ^
spectre/src/Domain/Orientation.cpp:43:9: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
        mapped_directions_[d].side() == Side::Upper
        ^
spectre/src/Domain/Orientation.cpp:44:15: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
            ? segmentIds[d]
              ^
spectre/src/Domain/Orientation.cpp:45:15: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
            : segmentIds[d].id_if_flipped();
              ^
spectre/src/Domain/Orientation.hpp:45:12: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
    return mapped_directions_[dim].dimension();
           ^
spectre/src/Domain/Orientation.hpp:51:18: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
               ? mapped_directions_[direction.dimension()]
                 ^
spectre/src/Domain/Orientation.hpp:52:18: warning: do not use array subscript when the index is not an integer constant expression; use gsl::at() instead [cppcoreguidelines-pro-bounds-constant-array-index]
               : mapped_directions_[direction.dimension()].opposite();
                 ^
spectre/src/Domain/SegmentId.hpp:74:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  return SegmentId(refinement_level_ - 1, index_ >> 1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~                 ~~
         {                                           }
spectre/src/Domain/SegmentId.hpp:85:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return SegmentId(refinement_level_ + 1, index_ << 1);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~                 ~~
           {                                           }
spectre/src/Domain/SegmentId.hpp:92:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  return SegmentId(refinement_level_,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
         {


spectre/src/Domain/SegmentId.hpp:74:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  return SegmentId(refinement_level_ - 1, index_ >> 1);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~                 ~~
         {                                           }
spectre/src/Domain/SegmentId.hpp:85:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return SegmentId(refinement_level_ + 1, index_ << 1);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~                 ~~
           {                                           }
spectre/src/Domain/SegmentId.hpp:92:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
  return SegmentId(refinement_level_,
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
         {

@osheamonn I'm not sure how legit these are, I'll leave it to you to figure out the right thing to do:

/usr/include/boost/math/tools/toms748_solve.hpp:209:35: warning: The left operand of '-' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
   T A = safe_div(T(fd - fb), T(d - b), tools::max_value<T>());
                                  ^
spectre/tests/Unit/Numerical/RootFinding/Test_OneDRootFinder.cpp:51:10: note: Calling 'find_root_of_function'
  root = find_root_of_function(f_lambda, lower, upper, abs_tol, rel_tol);
         ^
spectre/src/Numerical/RootFinding/RootFinder.hpp:39:17: note: Calling 'toms748_solve'
  auto result = boost::math::tools::toms748_solve(
                ^
/usr/include/boost/math/tools/toms748_solve.hpp:489:11: note: Calling 'toms748_solve'
   return toms748_solve(f, ax, bx, tol, max_iter, policies::policy<>());
          ^
/usr/include/boost/math/tools/toms748_solve.hpp:481:24: note: Calling 'toms748_solve'
   std::pair<T, T> r = toms748_solve(f, ax, bx, f(ax), f(bx), tol, max_iter, pol);
                       ^
/usr/include/boost/math/tools/toms748_solve.hpp:306:38: note: 'd' declared without an initial value
   T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe;
                                     ^
/usr/include/boost/math/tools/toms748_solve.hpp:312:4: note: Taking false branch
   if(a >= b)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
   if(tol(a, b) || (fa == 0) || (fb == 0))
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
/usr/include/boost/math/tools/toms748_solve.hpp:319:4: note: Taking false branch
   if(tol(a, b) || (fa == 0) || (fb == 0))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:329:4: note: Taking false branch
   if(boost::math::sign(fa) * boost::math::sign(fb) > 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:336:4: note: Taking false branch
   if(fa != 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
   while(count && (fa != 0) && !tol(a, b))
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
/usr/include/boost/math/tools/toms748_solve.hpp:360:4: note: Loop condition is true.  Entering loop body
   while(count && (fa != 0) && !tol(a, b))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:374:46: note: Left side of '||' is true
      bool prof = (fabs(fa - fb) < min_diff) || (fabs(fa - fd) < min_diff) || (fabs(fa - fe) < min_diff) || (fabs(fb - fd) < min_diff) || (fabs(fb - fe) < min_diff) || (fabs(fd - fe) < min_diff);
                                             ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:10: note: Assuming 'prof' is not equal to 0
      if(prof)
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:7: note: Taking true branch
      if(prof)
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:377:50: note: Passing value via 3rd parameter 'd'
         c = detail::quadratic_interpolate(a, b, d, fa, fb, fd, 2);
                                                 ^
/usr/include/boost/math/tools/toms748_solve.hpp:377:14: note: Calling 'quadratic_interpolate'
         c = detail::quadratic_interpolate(a, b, d, fa, fb, fd, 2);
             ^
/usr/include/boost/math/tools/toms748_solve.hpp:209:35: note: The left operand of '-' is a garbage value
   T A = safe_div(T(fd - fb), T(d - b), tools::max_value<T>());
                                  ^
/usr/include/boost/math/tools/toms748_solve.hpp:264:15: warning: The left operand of '-' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
   T q11 = (d - e) * fd / (fe - fd);
              ^
spectre/tests/Unit/Numerical/RootFinding/Test_OneDRootFinder.cpp:51:10: note: Calling 'find_root_of_function'
  root = find_root_of_function(f_lambda, lower, upper, abs_tol, rel_tol);
         ^
spectre/src/Numerical/RootFinding/RootFinder.hpp:39:17: note: Calling 'toms748_solve'
  auto result = boost::math::tools::toms748_solve(
                ^
/usr/include/boost/math/tools/toms748_solve.hpp:489:11: note: Calling 'toms748_solve'
   return toms748_solve(f, ax, bx, tol, max_iter, policies::policy<>());
          ^
/usr/include/boost/math/tools/toms748_solve.hpp:481:24: note: Calling 'toms748_solve'
   std::pair<T, T> r = toms748_solve(f, ax, bx, f(ax), f(bx), tol, max_iter, pol);
                       ^
/usr/include/boost/math/tools/toms748_solve.hpp:306:38: note: 'd' declared without an initial value
   T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe;
                                     ^
/usr/include/boost/math/tools/toms748_solve.hpp:312:4: note: Taking false branch
   if(a >= b)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
   if(tol(a, b) || (fa == 0) || (fb == 0))
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
/usr/include/boost/math/tools/toms748_solve.hpp:319:4: note: Taking false branch
   if(tol(a, b) || (fa == 0) || (fb == 0))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:329:4: note: Taking false branch
   if(boost::math::sign(fa) * boost::math::sign(fb) > 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:336:4: note: Taking false branch
   if(fa != 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
   while(count && (fa != 0) && !tol(a, b))
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
/usr/include/boost/math/tools/toms748_solve.hpp:360:4: note: Loop condition is true.  Entering loop body
   while(count && (fa != 0) && !tol(a, b))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:374:46: note: Left side of '||' is true
      bool prof = (fabs(fa - fb) < min_diff) || (fabs(fa - fd) < min_diff) || (fabs(fa - fe) < min_diff) || (fabs(fb - fd) < min_diff) || (fabs(fb - fe) < min_diff) || (fabs(fd - fe) < min_diff);
                                             ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:10: note: Assuming 'prof' is 0
      if(prof)
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:7: note: Taking false branch
      if(prof)
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:382:46: note: Passing value via 3rd parameter 'd'
         c = detail::cubic_interpolate(a, b, d, e, fa, fb, fd, fe);
                                             ^
/usr/include/boost/math/tools/toms748_solve.hpp:382:14: note: Calling 'cubic_interpolate'
         c = detail::cubic_interpolate(a, b, d, e, fa, fb, fd, fe);
             ^
/usr/include/boost/math/tools/toms748_solve.hpp:264:15: note: The left operand of '-' is a garbage value
   T q11 = (d - e) * fd / (fe - fd);
              ^
/usr/include/boost/math/tools/toms748_solve.hpp:387:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
      e = d;
        ^
spectre/tests/Unit/Numerical/RootFinding/Test_OneDRootFinder.cpp:51:10: note: Calling 'find_root_of_function'
  root = find_root_of_function(f_lambda, lower, upper, abs_tol, rel_tol);
         ^
spectre/src/Numerical/RootFinding/RootFinder.hpp:39:17: note: Calling 'toms748_solve'
  auto result = boost::math::tools::toms748_solve(
                ^
/usr/include/boost/math/tools/toms748_solve.hpp:489:11: note: Calling 'toms748_solve'
   return toms748_solve(f, ax, bx, tol, max_iter, policies::policy<>());
          ^
/usr/include/boost/math/tools/toms748_solve.hpp:481:24: note: Calling 'toms748_solve'
   std::pair<T, T> r = toms748_solve(f, ax, bx, f(ax), f(bx), tol, max_iter, pol);
                       ^
/usr/include/boost/math/tools/toms748_solve.hpp:306:38: note: 'd' declared without an initial value
   T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe;
                                     ^
/usr/include/boost/math/tools/toms748_solve.hpp:312:4: note: Taking false branch
   if(a >= b)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
   if(tol(a, b) || (fa == 0) || (fb == 0))
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:319:7: note: Left side of '||' is false
/usr/include/boost/math/tools/toms748_solve.hpp:319:4: note: Taking false branch
   if(tol(a, b) || (fa == 0) || (fb == 0))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:329:4: note: Taking false branch
   if(boost::math::sign(fa) * boost::math::sign(fb) > 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:336:4: note: Taking false branch
   if(fa != 0)
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
   while(count && (fa != 0) && !tol(a, b))
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:360:10: note: Left side of '&&' is true
/usr/include/boost/math/tools/toms748_solve.hpp:360:4: note: Loop condition is true.  Entering loop body
   while(count && (fa != 0) && !tol(a, b))
   ^
/usr/include/boost/math/tools/toms748_solve.hpp:374:46: note: Left side of '||' is true
      bool prof = (fabs(fa - fb) < min_diff) || (fabs(fa - fd) < min_diff) || (fabs(fa - fe) < min_diff) || (fabs(fb - fd) < min_diff) || (fabs(fb - fe) < min_diff) || (fabs(fd - fe) < min_diff);
                                             ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:10: note: Assuming 'prof' is not equal to 0
      if(prof)
         ^
/usr/include/boost/math/tools/toms748_solve.hpp:375:7: note: Taking true branch
      if(prof)
      ^
/usr/include/boost/math/tools/toms748_solve.hpp:387:9: note: Assigned value is garbage or undefined
      e = d;
        ^

from spectre.

nilsdeppe avatar nilsdeppe commented on September 6, 2024

Another update on this:

@wthrowe

/home/nils/SpECTRE/spectre/src/Time/Slab.cpp:14:44: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
Time Slab::start() const noexcept { return Time(*this, 0); }
                                           ^~~~~~       ~~
                                           {            }
/home/nils/SpECTRE/spectre/src/Time/Slab.cpp:16:42: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
Time Slab::end() const noexcept { return Time(*this, 1); }
                                         ^~~~~~       ~~
                                         {            }
/home/nils/SpECTRE/spectre/src/Time/Slab.cpp:18:52: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
TimeDelta Slab::duration() const noexcept { return TimeDelta(*this, 1); }
                                                   ^~~~~~~~~~~       ~~
                                                   {                 }
/home/nils/SpECTRE/spectre/src/Time/Slab.cpp:42:11: warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]
namespace std {
          ^

/home/nils/SpECTRE/spectre/src/Time/Time.cpp:83:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
    return TimeDelta(a.slab(), a.fraction() - b.fraction());
           ^~~~~~~~~~~                                    ~~
           {                                              }
/home/nils/SpECTRE/spectre/src/Time/Time.cpp:152:11: warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]
namespace std {

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/bits/stl_tree.h:162:9: warning: move constructor initializes class member by calling a copy constructor [cert-oop11-cpp]
      : _M_key_compare(__x._M_key_compare)
        ^
/home/nils/SpECTRE/spectre/tests/Unit/Utilities/Test_CachedFunction.cpp:22:21: note: copy constructor being called
  auto comparator = [&comparator_used, not_trivially_copyable=std::string{}](
                    ^
/home/nils/SpECTRE/spectre/tests/Unit/Utilities/Test_CachedFunction.cpp:22:21: note: candidate move constructor here


/home/nils/SpECTRE/spectre/src/Time/TimeSteppers/AdamsBashforthN.hpp:505:7: warning: 'push_back' is called inside a loop; consider pre-allocating the vector capacity before the loop [performance-inefficient-vector-operation]
      side_indices.push_back(step_containing_time(
      ^

@gsb76

/home/nils/SpECTRE/spectre/src/Domain/ElementId.cpp:75:11: warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]
namespace std {
          ^
/home/nils/SpECTRE/spectre/src/Domain/ElementId.cpp:96:11: warning: modification of 'std' namespace can result in undefined behavior [cert-dcl58-cpp]
namespace std {

from spectre.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.