-
Notifications
You must be signed in to change notification settings - Fork 438
Pure-SoA particle type lacks compile-time guard that position components exist #5062
Copy link
Copy link
Closed
Description
- Type: Correctness / API safety
- Severity: Medium
- Component: Pure-SoA particle container/type contracts
- Location:
Src/Particle/AMReX_ParticleContainer.H:1562Src/Particle/AMReX_ParticleTile.H:432
Problem
ParticleContainerPureSoA<T_NArrayReal,...> allows any T_NArrayReal, but pure-SoA code assumes the first AMREX_SPACEDIM real components are particle positions (e.g., \ SoAParticle::pos() directly indexes m_rdata[0..AMREX_SPACEDIM-1]).
There is no compile-time guard enforcing T_NArrayReal >= AMREX_SPACEDIM.
Impact
- Invalid template instantiations compile but can perform out-of-bounds accesses at runtime.
- Failure mode is silent UB rather than a clear compile-time error.
Suggested patch
Add a compile-time contract for pure-SoA instantiations.
--- a/Src/Particle/AMReX_ParticleContainer.H
+++ b/Src/Particle/AMReX_ParticleContainer.H
@@
class ParticleContainer_impl : public ParticleContainerBase
{
public:
@@
+ static_assert(!ParticleType::is_soa_particle || T_NArrayReal >= AMREX_SPACEDIM,
+ "Pure SoA particle containers require at least AMREX_SPACEDIM real components for positions");(Equivalent static_assert in SoAParticle<T_NArrayReal,...> is also acceptable.)
Prepared by Codex
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels