[BUG]: Pure virtual method overriding using mixin class gives: Tried to call pure virtual function …
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
再現可能な例にある C++ の mixin、抽象クラス、trampoline のセットアップから始め、次に対応する Python の多重継承ケースを実行します。pure virtual call がどのようにディスパッチされるかを追跡します。mixin が提供する f() の実装が使われ、pure-virtual error が発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
2.13.5
Problem description
I cant override pure virtual functions using mixin classes. Pybind does not realize that the function in question does exist but is provided by the mixin class.
Reproducible example code
struct M {
int f() { return 1; }
};
struct A {
virtual int f() = 0;
};
// Imagine a trampoline class AT for A here
PYBIND11_MODULE(example, m) {
pybind11::class_<M>(m, "Mixin")
.def("f", &M::f);
pybind11::class_<A, AT>(m, "Abstract")
.def("f", &A::f);
}
class Derived(M, A):
...
d = D()
d.foo()
The last statement throws "Tried to call pure virtual function". For example in plain Python this works as expected:
class A():
def f(self):
pass
class M:
def f(self):
return "mixed in"
class D(M, A):
pass
d = D()
print(d.f())
Is this a regression? Put the last known working version here if it is.
Not a regression
- 主要言語
- C++
- スター
- 18k
- フォーク
- 2.3k
- 平均マージ
- 5日 7時間
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pybind/pybind11 のほかの issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 3 日以内に返信
-
triage
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
pybind/pybind11#5604 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 3 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
pybind/pybind11#747 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
array_t::at() returns a misaligned reference when the stride is not a multiple of alignof(T)対応中かも @henryiii が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 3 日以内に返信
pybind/pybind11 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
patrick-hudson/put.gd-desktop#2044 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
uxlfoundation/oneDNN#6604 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: RoundToNearest truncates in plugins compiled with spcomp 1.13対応中かも @fmu1337 が今日担当しました。 オープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
alliedmodders/sourcemod#2627 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信