Signed Overflow warnings in CellInterval
For certain CellIntervals
, some gcc7 setups throw a assuming signed overflow does not occur when assuming that (X - c) > X is always false
warning, when using accessing the begin()
iterator, as there are int
comparisons in the empty()
check. Such cell intervals occur e.g. when consistently setting boundary conditions in refinement applications.
This warning prohibits such code in waLBerla tests, as all warnings are treated as errors and the pipeline (for me it was gcc_7_hybrid
) will not pass.
NON-WORKING MINIMAL EXAMPLE:
#include <blockforest/Initialization.h>
#include <blockforest/SetupBlockForest.h>
#include <core/debug/TestSubsystem.h>
namespace walberla {
const uint_t FieldGhostLayers = uint_t(4);
int main()
{
debug::enterTestMode();
auto blocks = blockforest::createUniformBlockGrid(uint_t(1), uint_t(1), uint_t(1),
uint_t(10), uint_t(10), uint_t(10),
real_t(1), true);
CellInterval domainBB = blocks->getDomainCellBB();
auto ghost = cell_idx_t(FieldGhostLayers);
domainBB.expand( ghost );
// lowerX
CellInterval lowerX( domainBB.xMin(), domainBB.yMin(), domainBB.zMin(),
domainBB.xMin() + ghost - cell_idx_c(1), domainBB.yMax(), domainBB.zMax());
for( const auto cell : lowerX ) {
// DUMMY CODE to avoid unused variable warning - can be anything
WALBERLA_LOG_INFO_ON_ROOT("x=" << cell.x() )
}
return EXIT_SUCCESS;
}
} // namespace walberla
int main()
{
return walberla::main();
}