nullptr as default argument results in unreported exception during import
- 主要語言
- C++
- 星號
- 537
- 分支
- 223
- 平均合併
- 11 小時 22 分鐘
- 30 天內合併 PR
- 2
描述
The code at the bottom can be compiled like so:
```
clang++ -std=c++11 -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -shared -o foo.so nullptr_error.cpp -L/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib -lpython3.5 -L/opt/local/lib -lboost_python
```
When importing the resulting module in Python I see the following error:
```
>>> import foo
Traceback (most recent call last):
File "", line 1, in
SystemError: initialization of foo raised unreported exception
```
If I replace `nullptr` with `NULL`, then there is no error. This is with Boost 1.59 installed via MacPorts on the latest version of OS X with the latest version of Xcode.
``` c++
#include
struct Foo
{
Foo() : foo_(1) {}
void setFoo(int * foo = nullptr) { foo_ = foo ? *foo : 1; }
int getFoo() { return foo_; }
int foo_;
};
BOOST_PYTHON_MODULE(foo)
{
boost::python::class_("Foo", boost::python::init<>())
.def("setFoo", &Foo::setFoo, ( boost::python::arg("foo")=nullptr))
.def("getFoo", &Foo::getFoo)
;
}
```
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
Start with the reproducer in nullptr_error.cpp and build it using the command in the issue, then test importing foo in Python. Compare the nullptr and NULL default-argument cases, and verify that the module imports without an unreported exception while Foo.setFoo still supports its default behavior.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- cpp, python
- 領域
- backend-api-design
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100