Fragment::covalentRadii() writes every value to result[0] and returns van der Waals radii
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Empieza en src/tdat/chemistry/Fragment.C alrededor de la línea 3897, donde Fragment::covalentRadii() nunca avanza iter, así que solo se escribe result[0]. Compara con Fragment::atomicNumbers() unas líneas más abajo, que usa (*iter++). Comprueba que nada llama a covalentRadii (la variable local de las líneas 1810-1929 no tiene relación). Está terminado cuando el método se elimina o se corrige y se renombra para que coincida con los radios de van der Waals que devuelve, y la declaración en include/tdat/Fragment.H:239 se actualiza en consecuencia.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
src/tdat/chemistry/Fragment.C:3897, in full:
///////////////////////////////////////////////////////////////////////////////
//
// Description
// Return a Dynamically Allocated, c-style, Ordered Array of crs.
// The Caller must Deallocate the Array Memory.
//
///////////////////////////////////////////////////////////////////////////////
double* Fragment::covalentRadii(void) const
{
TPerTab tpt;
double* result = new double[numAtoms()];
double* iter = result;
int cnt = p_atoms.size();
for (int idx=0; idx<cnt; idx++) {
(*iter) = tpt.vwr(tpt.atomicNumber(p_atoms[idx]->atomicSymbol()));
}
return result;
}
Two defects.
1. The output pointer never advances. iter is assigned but never
incremented, so every atom's value is written to result[0] and
result[1..numAtoms()-1] is returned uninitialised. The caller, which the
comment tells to delete[] the array, would read heap garbage for every atom
after the first.
The sibling function immediately below it, Fragment::atomicNumbers()
(Fragment.C:3917), is the same loop written correctly, with (*iter++).
2. It is misnamed. The function is covalentRadii, but it calls
TPerTab::vwr — it returns van der Waals radii. TPerTab has a separate
covalentRadius(int) (include/tdat/TPerTab.H:81), which this does not call.
The doc comment ("an Ordered Array of crs") says covalent radii too.
Callers
None. Searching the whole tree for covalentRadii:
include/tdat/Fragment.H:239— the declaration,
virtual double* covalentRadii(void) const;src/tdat/chemistry/Fragment.C:3897— this definition.src/tdat/chemistry/Fragment.C:1810-1929— an unrelated local variable
of the same name in the bond-generation code. It is a plain
double* covalentRadii = new double[nAtoms], filled from
tpt.covalentRadius(num) * tpt.covalentRadiusTolerance(num)anddelete[]d
at line 1929. That code is correct and does use covalent radii; it does not
call the method.include/tdat/TPerTab.H:87-88andsrc/tdat/chemistry/TPerTab.C:205-229—
parameter names ofTPerTab::writeRadiiOverrides(double*, double*, double*). Unrelated.
So the method is declared once, defined once, and called from nowhere.
Severity
A latent defect in dead code, not a live bug: nothing currently calls it, so
nothing currently reads the uninitialised tail. But it is public and
virtual, so a subclass can override it and any future caller can reach it,
and the misnaming means a caller would get the wrong quantity even after the
loop bug is fixed. It allocates with new[] and its comment makes the caller
responsible for freeing — an interface that is easy to use wrongly even when
it works.
Recommendation
Delete it, or fix and rename it (vanderWaalsRadii(), returning a
std::vector<double> rather than a raw new[] array) — but it should not be
left as it is.
This matters now because of #1332: surface-area work is exactly the kind of
code that reaches for a Fragment method named covalentRadii() or sitting
next to one, and #1332 turns on which radius set is used. A function that is
named for one radius set and silently returns another, with only its first
element valid, is the worst possible thing for that code to find.
- Lenguaje dominante
- C
- Estrellas
- 10
- Forks
- 8
- Merge medio
- 6 h 32 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de FriendsofECCE/ECCE
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
FriendsofECCE/ECCE#1358 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FriendsofECCE/ECCE#1353 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
FriendsofECCE/ECCE#1348 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
FriendsofECCE/ECCE#1347 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
FriendsofECCE/ECCE#1345 ·
Todos los issues de FriendsofECCE/ECCE
Issues similares
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values insideAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
kamgurgul/mib2q-carplay#74 ·
-
Claude:NotNeeded GPT:NotABug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
open5gs/open5gs#5195 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
documentation needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
X11Libre/xserver#4255 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
antoxa2584x/nfsu2-sw#52 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
KalicoCrew/kalico#1120 ·
Los mantenedores suelen responder en 3 días