[pull] develop from lammps:develop#164
Merged
Merged
Conversation
The spin/dipole/long pair style and its ewald/dipole/spin and pppm/dipole/spin kspace partners gave dipolar energies that disagreed with spin/dipole/cut and the analytical result, and were not independent of the real-space cutoff when shifting work between the short- and long-range parts. Real-space pair (pair_spin_dipole_long): - compute_long: the screened dipolar field is B2*r^2*(sj.eij)*eij - B1*sj. The r^2 (rsq) factor on the B2 term was missing, which corrupted both the precession field and the energy (evdwl = -0.5*hbar*sp.fmi). With the fix this reduces to compute_dipolar in the cut style as g_ewald -> 0. - compute_long_mech was accumulated into fmi instead of fi (so there were no real-space mechanical forces at all), and was missing the r^2 factor on the (si.eij)(sj.eij) term, the overall factor of r, and the sign. Both helpers now take rsq. - The pair virial was tallied with rij = x_j - x_i instead of x_i - x_j, giving the wrong sign (attractive pairs reported positive pressure) and preventing cancellation against the reciprocal-space virial. The same one-line sign fix is applied to spin/dipole/cut. - write_restart/read_restart wrote/read the double cutoff with sizeof(int). Reciprocal space (ewald_dipole_spin, pppm_dipole_spin): - fm_long (the kspace precession contribution) was missing the per-atom spin norm sp[i][3]; ewald additionally had the wrong sign. The slab corrections used spscale instead of spscale2 and also dropped sp[i][3]. - mu_0 was 785.15 in the kspace styles but 784.15 in the pair styles, so the real- and reciprocal-space prefactors did not match. - mu2 used in the g_ewald estimate dropped the mub2mu0 prefactor. Verified on the issue reproducer and periodic spin lattices that the total energy, mechanical forces, and pressure are independent of the real-space cutoff and of g_ewald, that spin/dipole/long now matches spin/dipole/cut and the analytical dipolar energy, and that pppm/dipole/spin converges to ewald/dipole/spin. https://claude.ai/code/session_017vJXz7igWW7Rv1hnLgGmgM Co-authored-by: stanmoore1 <stanmoore1@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
Coverity Scan flagged 13 constructors with uninitialized pointer
members ("Uninitialized pointer field"). Per the LAMMPS coding standard
(doc/src/Modify_style.rst, Developer_write_bond.rst) all class-member
pointers must be initialized to nullptr in the constructor, so that
destructor deallocation is always safe and a style that is destroyed and
recreated (for example after an exception) does not free a stale pointer.
On a fresh process the first heap pages happen to be zero, which masks
the omission; on reused pages an uninitialized member pointer is garbage
and the destructor's delete/memory->destroy becomes a double free or
segfault.
The fix uses member initializer lists in header declaration order (so no
-Wreorder warnings at high warning levels) and folds in any pre-existing
in-body nullptr assignments.
Affected styles: pair coul/esp, lj/cut/coul/esp, lj/cut/soft/gapsys,
bondval, bondval/vec, oxdna3/xstk, ldd; angle/dihedral class2xe;
fix gemc, granular/mdr, surface/local; pair surf/granular.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MOLECULE package: 18 bond/angle/dihedral/improper/pair styles left coefficient and table pointer members uninitialized in their constructors. Per the LAMMPS coding standard all class-member pointers must be set to nullptr in the constructor so that a destructor running after a partially-constructed object (e.g. an exception during setup, or a deleted-then-recreated style) frees only nullptr instead of an indeterminate address. Pointers are added to the constructor initializer list in declaration order (-Wreorder clean). The table styles (angle/bond/dihedral) keep their existing "tables = nullptr" body assignment and only gain the previously-missed theta0/r0/tabindex members; pair_hbond/dreiding/lj gains donor/acceptor/ type2param (its Param *params was already nulled). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the ASPHERE package (9 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the BOCS package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the BODY package (7 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the CG-DNA package (12 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the CLASS2 package (7 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the COLLOID package (5 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DIELECTRIC package (9 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DIPOLE package (4 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DPD-BASIC package (2 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DPD-MESO package (5 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DPD-REACT package (4 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DPD-SMOOTH package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the DRUDE package (4 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the EFF package (3 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the FEP package (10 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the GRANULAR package (6 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the KSPACE package (8 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MANYBODY package (10 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MC package (4 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the OPENMP package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the QEQ package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the REAXFF package (5 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the REPLICA package (12 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the RIGID package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the SHOCK package (1 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the SPIN package (11 file(s)): the constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean). This makes a destructor that runs on a partially-constructed object (e.g. after an exception during setup, or a deleted-then-recreated style) free only nullptr instead of an indeterminate address, per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the AMOEBA package (3 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the BPM package (1 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the ELECTRODE package (2 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
…tors Coverity "Uninitialized pointer field" defects in the EXTRA-COMPUTE package (7 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the EXTRA-FIX package (11 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
…ctors Coverity "Uninitialized pointer field" defects in the EXTRA-MOLECULE package (17 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the EXTRA-PAIR package (29 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the INTERLAYER package (5 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MACHDYN package (4 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MANIFOLD package (1 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MESONT package (2 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MISC package (3 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the ML-SNAP package (3 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the MOFFF package (5 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the PERI package (1 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the PHONON package (2 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the RHEO package (5 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the SMTBQ package (1 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the SPH package (8 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in the YAFF package (7 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object frees only nullptr per the coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Coverity "Uninitialized pointer field" defects in core src/ classes (70 file(s)): constructor initializer lists now null every previously-uninitialized class-member pointer, in declaration order (-Wreorder clean), so a destructor on a partially-constructed object (e.g. after a setup exception) frees only nullptr per the LAMMPS coding standard. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
A first automated sweep skipped a few constructors whose declarations defeat simple parsing. Add the missing nullptr initializers (declaration order, -Wreorder clean): - npair.cpp: atom2bin and binatoms_hash_multi (the latter a pointer to a templated container whose embedded commas hid it from the parser). - neighbor.cpp: corners, a pointer-to-array member (double (*corners)[...]). - fix_shardlow.cpp: list (its sibling v_t0 is a double (*)[3] member that confused the initializer-order analysis). - compute_entropy_atom.cpp / compute_erotate_asphere.cpp: list and avec_ellipsoid/avec_line/avec_tri (constructors whose class name is split across two source lines). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
The sweep that added the nullptr initializers left each constructor's opening brace on the same line as the now multi-line initializer list. Normalize the affected constructors to the project's clang-format style: opening brace on its own line, initializer list reflowed at the 99-column limit. clang-format-clean files were reformatted with "clang-format --lines" limited to the constructor range; clang-format-off files (where clang-format is a no-op) had the brace moved with an equivalent text edit. No non-constructor code is changed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
The automated pointer-init pass misclassified six class members that are
arrays of pointers (T *name[N]) as scalar pointers and emitted name(nullptr)
initializers, which do not compile (cannot assign nullptr to an array type):
src/DPD-REACT/fix_rx.cpp diagnosticCounterPerODE (int *[5])
src/fix_wall_reflect.cpp varstr (char *[6])
src/GRANULAR/granular_model.cpp sub_models (GranSubMod *[])
src/min_hftn.cpp _daAVectors, _daExtraAtom, _daExtraGlobal (double *[])
Use value-initialization name{} instead, which zero-initializes every
element to nullptr and is valid for array types. For min_hftn this also
closes a genuine gap: the body loop nulled _daExtraGlobal only from index 1
and never touched _daAVectors, so those elements were previously
uninitialized.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HrAVWctE6TRM5n875zpBnu
Fix long-range spin dipole energy, forces, and pressure (issue #4717)
Initialize uninitialized class-member pointers in constructors (Coverity)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )