Skip to content

Commit 0338c0f

Browse files
authored
Fix comparison with zero warning (#4828)
This removes warnings like: ``` AMReX_Array.H(158): warning #186-D: pointless comparison of unsigned integer with zero ``` that can arise in cases where `NAR` or `NAI` is zero.
1 parent ef4d330 commit 0338c0f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Src/Particle/AMReX_WriteBinaryParticleData.H

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ rPackParticleData (const PTD& ptd, int idx, typename PTD::RealType * rdata_ptr,
260260

261261
constexpr int real_start_offset = PTD::ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
262262

263-
for (int j = real_start_offset; j < PTD::NAR; ++j) {
264-
if (write_real_comp[PTD::ParticleType::NReal + j - real_start_offset]) {
265-
rdata_ptr[rout_index] = ptd.rdata(j)[idx];
266-
rout_index++;
263+
if constexpr (PTD::NAR > 0) {
264+
for (int j = real_start_offset; j < PTD::NAR; ++j) {
265+
if (write_real_comp[PTD::ParticleType::NReal + j - real_start_offset]) {
266+
rdata_ptr[rout_index] = ptd.rdata(j)[idx];
267+
rout_index++;
268+
}
267269
}
268270
}
269271

@@ -296,10 +298,12 @@ iPackParticleData (const PTD& ptd, int idx, typename PTD::IntType * idata_ptr,
296298
}
297299
}
298300

299-
for (int j = 0; j < PTD::NAI; ++j) {
300-
if (write_int_comp[PTD::ParticleType::NInt + j]) {
301-
idata_ptr[iout_index] = ptd.idata(j)[idx];
302-
iout_index++;
301+
if constexpr (PTD::NAI > 0) {
302+
for (int j = 0; j < PTD::NAI; ++j) {
303+
if (write_int_comp[PTD::ParticleType::NInt + j]) {
304+
idata_ptr[iout_index] = ptd.idata(j)[idx];
305+
iout_index++;
306+
}
303307
}
304308
}
305309

0 commit comments

Comments
 (0)