提高::蟒蛇::枚举大型UINT32崩溃 [英] boost::python::enum large uint32 crash

查看:127
本文介绍了提高::蟒蛇::枚举大型UINT32崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想换一个C ++枚举使用boost :: python的(提高1.58)。枚举类型为uint32_t的,并且所有值都没有问题,除了包装大量,开始在0x4000的0000。

包裹的0x4000的0000铅枚举值(UINT32)尝试在enum.hpp崩溃,第95行(提高1.58)。我观察与VS2012(WIN7)这一行为。

任何想法?

例如:

 枚举EnumName:uint32_t的
{
   valueOK = 0x20000000,
   valueCrash =为0x40000000
};提高::蟒蛇:: enum_< EnumName>(EnumName)
        .value的(valueOK,valueOK)
        .value的(valueCrash,valueCrash)
        ;


解决方案

我无法重现该问题。使用

<大骨节病> 住在Coliru

 的#include&LT;升压/ python.hpp&GT;枚举EnumName:uint32_t的
{
   valueOK = 0x20000000,
   valueCrash =为0x40000000
};
EnumName identity_(EnumName X){返回X; }BOOST_PYTHON_MODULE(测试)
{
    提高::蟒蛇:: enum_&LT; EnumName&GT;(EnumName)
        .value的(valueOK,valueOK)
        .value的(valueCrash,valueCrash)
        ;    //提振::蟒蛇:: DEF(身份,identity_);
}

楼:

  G ++  -  5 -std = C ++ 11 -pedantic -Wall -fPIC -fsanitize =未定义-g -O0 -isystem /家庭/ sehe /自定义/游标/包括-isystem /usr/include/python2.7 -pthread TEST.CPP -c -o test.o
G ++ - 5 -std = C ++ 11 -pedantic -Wall -fPIC -fsanitize =未定义-g -O0 -isystem /家庭/ sehe /自定义/游标/包括-isystem /usr/include/python2.7 -pthread测试。 Ø-shared -o test.so -lpython2.7 -lboost_python

使用

  $ python2.7&LT;&LT;&LT; 从测试导入*;打印(EnumName.valueCrash + 0);
1073741824

I am trying to wrap a c++ enum using boost::python (boost 1.58). An enum is of type uint32_t and all values are wrapped without problem except large numbers, starting at 0x4000 0000.

An attempt to wrap enum value (uint32) of 0x4000 0000 lead to crash at enum.hpp, line 95 (boost 1.58). i observe this behaviour with VS2012 (win7).

Any ideas?

example:

enum EnumName: uint32_t
{
   valueOK = 0x20000000,
   valueCrash = 0x40000000
};

boost::python::enum_<EnumName>("EnumName")
        .value("valueOK", valueOK)
        .value("valueCrash", valueCrash)
        ;

解决方案

I can't reproduce the issue. Using

Live On Coliru

#include <boost/python.hpp>

enum EnumName: uint32_t
{
   valueOK = 0x20000000,
   valueCrash = 0x40000000
};


EnumName identity_(EnumName x) { return x; }

BOOST_PYTHON_MODULE(test)
{
    boost::python::enum_<EnumName>("EnumName")
        .value("valueOK", valueOK)
        .value("valueCrash", valueCrash)
        ;

    //boost::python::def("identity", identity_);
}

Building:

g++-5 -std=c++11 -Wall -pedantic -fPIC -fsanitize=undefined -g -O0 -isystem /home/sehe/custom/nonius/include -isystem /usr/include/python2.7 -pthread test.cpp -c -o test.o
g++-5 -std=c++11 -Wall -pedantic -fPIC -fsanitize=undefined -g -O0 -isystem /home/sehe/custom/nonius/include -isystem /usr/include/python2.7 -pthread test.o -shared -o test.so -lpython2.7 -lboost_python

Using

$ python2.7 <<< 'from test import *; print (EnumName.valueCrash+0);'
1073741824

这篇关于提高::蟒蛇::枚举大型UINT32崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆