Fragment::covalentRadii() writes every value to result[0] and returns van der Waals radii
まだ誰も着手していません。
評価
調査の方向性
src/tdat/chemistry/Fragment.C の 3897 行目付近から始めてください。ここで Fragment::covalentRadii() は iter を進めないため、result[0] にしか書き込まれません。数行下にある Fragment::atomicNumbers() は (*iter++) を使っているので、これと比較してください。covalentRadii を呼び出している箇所がないことを確認してください(1810~1929 行目のローカル変数は無関係です)。メソッドを削除するか修正して、返している van der Waals 半径に合う名前に変更し、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分
- マージ済み PR(30日)
- 1
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 日以内に返信