From 45571003cc871f1883947807831b807e9fa7ea5a Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Wed, 3 Dec 2025 13:12:35 -0800 Subject: [PATCH] Fix comparison with zero warning --- Src/Particle/AMReX_WriteBinaryParticleData.H | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Src/Particle/AMReX_WriteBinaryParticleData.H b/Src/Particle/AMReX_WriteBinaryParticleData.H index 51a05a6a33..f86e31c670 100644 --- a/Src/Particle/AMReX_WriteBinaryParticleData.H +++ b/Src/Particle/AMReX_WriteBinaryParticleData.H @@ -260,10 +260,12 @@ rPackParticleData (const PTD& ptd, int idx, typename PTD::RealType * rdata_ptr, constexpr int real_start_offset = PTD::ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0; - for (int j = real_start_offset; j < PTD::NAR; ++j) { - if (write_real_comp[PTD::ParticleType::NReal + j - real_start_offset]) { - rdata_ptr[rout_index] = ptd.rdata(j)[idx]; - rout_index++; + if constexpr (PTD::NAR > 0) { + for (int j = real_start_offset; j < PTD::NAR; ++j) { + if (write_real_comp[PTD::ParticleType::NReal + j - real_start_offset]) { + rdata_ptr[rout_index] = ptd.rdata(j)[idx]; + rout_index++; + } } } @@ -296,10 +298,12 @@ iPackParticleData (const PTD& ptd, int idx, typename PTD::IntType * idata_ptr, } } - for (int j = 0; j < PTD::NAI; ++j) { - if (write_int_comp[PTD::ParticleType::NInt + j]) { - idata_ptr[iout_index] = ptd.idata(j)[idx]; - iout_index++; + if constexpr (PTD::NAI > 0) { + for (int j = 0; j < PTD::NAI; ++j) { + if (write_int_comp[PTD::ParticleType::NInt + j]) { + idata_ptr[iout_index] = ptd.idata(j)[idx]; + iout_index++; + } } }