Repository navigation
Fix compiler warnings after Catch2 upgrade - #63
Merged
Merged
Conversation
Finii
commented
Nov 6, 2026
Member
[why]
We get a warning for the tests with accumulate over floating
accumulators because the expected result is given as integer:
In file included from ../subprojects/Catch2-3.16.1/src/catch2/internal/catch_assertion_handler.hpp:12,
from ../subprojects/Catch2-3.16.1/src/catch2/internal/catch_test_macro_impl.hpp:12,
from ../subprojects/Catch2-3.16.1/src/catch2/catch_test_macros.hpp:11,
from ../subprojects/Catch2-3.16.1/src/catch2/catch_template_test_macros.hpp:20,
from ../tests/test_statistics.cc:35:
../subprojects/Catch2-3.16.1/src/catch2/internal/catch_decomposer.hpp: In instantiation of ‘constexpr std::enable_if_t<((bool)std::conjunction<Catch::Detail::is_eq_comparable_impl<typename std::remove_reference<_Tp>::type&, typename std::remove_reference<_Arg>::type&, void>, Catch::capture_by_value<RhsT> >::value), Catch::BinaryExpr<LhsT, RhsT> > Catch::operator==(ExprLhs<LhsT>&&, RhsT) [with LhsT = float; RhsT = int; std::enable_if_t<((bool)std::conjunction<Detail::is_eq_comparable_impl<typename std::remove_reference<_Tp>::type&, typename std::remove_reference<_Arg>::type&, void>, capture_by_value<RhsT> >::value), BinaryExpr<LhsT, RhsT> > = BinaryExpr<float, int>; typename std::remove_reference<_Tp>::type = float; typename std::remove_reference<_Arg>::type = int]’:
../tests/test_statistics.cc:481:9: required from ‘void CATCH2_INTERNAL_TEMPLATE_TEST_34() [with TestType = float]’
482 | [](TestType accu, TestType* el) { return accu + *el; }) == 14);
../tests/test_statistics.cc:457:1: required from ‘void {anonymous}::ns_CATCH2_INTERNAL_TEMPLATE_TEST_35::reg_test(Catch::Detail::TypeList<Ts ...>, Catch::NameAndTags) [with Ts = {float}]’
83 | INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/test_statistics.cc:457:1: required from ‘{anonymous}::ns_CATCH2_INTERNAL_TEMPLATE_TEST_35::CATCH2_INTERNAL_TEMPLATE_TEST_35<Types>::CATCH2_INTERNAL_TEMPLATE_TEST_35() [with Types = {Catch::Detail::TypeList<int>, Catch::Detail::TypeList<float>}]’
90 | (void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../tests/test_statistics.cc:457:1: required from here
94 | TestName<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
| ^
../subprojects/Catch2-3.16.1/src/catch2/internal/catch_decomposer.hpp:308:53: warning: conversion from ‘int’ to ‘float’ may change value [-Wconversion]
308 | return { static_cast<bool>( lhs.getLhs() op rhs ), \
| ^~~
../subprojects/Catch2-3.16.1/src/catch2/internal/catch_decomposer.hpp:345:5: note: in expansion of macro ‘CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR’
345 | CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( eq, == )
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler: gcc 15.2.0
[how]
Compare with a variable of the same type as the result (accumulator
value).
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
Finii
force-pushed
the
cleanup/compiler-warnings
branch
from
November 9, 2026 11:48
c3e82aa to
83585d4
Compare
Member
Author
|
Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.