Fragment::covalentRadii() writes every value to result[0] and returns van der Waals radii
還沒有人認領這個 Issue。
評估
研究方向
從 src/tdat/chemistry/Fragment.C 約第 3897 行開始,此處 Fragment::covalentRadii() 從未推進 iter,因此只寫入了 result[0]。請與下方幾行的 Fragment::atomicNumbers() 比對,後者使用的是 (*iter++)。檢查是否有地方呼叫 covalentRadii(第 1810-1929 行的區域變數與此無關)。當該方法被刪除或修正,並重新命名以符合其回傳的凡得瓦半徑,同時 include/tdat/Fragment.H:239 中的宣告也相應更新時,任務完成。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- C
- 星號
- 10
- 分支
- 8
- 平均合併
- 6 小時 32 分鐘
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
FriendsofECCE/ECCE 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
FriendsofECCE/ECCE#1358 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
FriendsofECCE/ECCE#1353 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
FriendsofECCE/ECCE#1348 ·
-
難度 2/5 1-3 小時 新手友好度 76/100
FriendsofECCE/ECCE#1347 ·
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
FriendsofECCE/ECCE#1345 ·
查看 FriendsofECCE/ECCE 的全部 Issue
相似的 Issue
-
[Android Auto] MU1017 (MHI2Q_JP_AUG22_P1017) cluster map works with a pinned profile — values inside未關閉
難度 1/5 1 小時以內 新手友好度 92/100
kamgurgul/mib2q-carplay#74 ·
-
Claude:NotNeeded GPT:NotABug triage
難度 2/5 1-3 小時 新手友好度 78/100
open5gs/open5gs#5195 · 1 則留言 ·
維護者通常 1 天內回覆
-
documentation needs-triage
難度 2/5 1-3 小時 新手友好度 68/100
X11Libre/xserver#4255 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 84/100
antoxa2584x/nfsu2-sw#52 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
KalicoCrew/kalico#1120 ·
維護者通常 3 天內回覆