Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Warning C4267 in vector_indexing_suite.hpp and indexing_suite_detail.hpp

未关闭
#184 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp, python
领域
api

调研方向

从报告的警告位置开始检查 boost/python/suite/indexing/vector_indexing_suite.hpp 和 boost/python/suite/indexing/detail/indexing_suite_detail.hpp。使用 Visual Studio 2017 编译提供的 vector_indexing_suite 示例,并检查受影响的索引算术。完成的标准是示例在没有 C4267 警告的情况下构建,并保持索引行为不变。

由索引模型根据 Issue 内容生成。

描述

Usage of boost::python::vector_indexing_suite leads to a warning :
boost/python/suite/indexing/detail/indexing_suite_detail.hpp(619): warning C4267: '+=': conversion from 'size_t' to 'long', possible loss of data

Here's a snippet of code that produces the warning.

#pragma warning(push)
#pragma warning(disable:4244)
// See https://svn.boost.org/trac10/ticket/3353 for 4244
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#pragma warning(pop)

void test()
{
    boost::python::class_<std::vector<double>>("DoubleVec")
        .def(boost::python::vector_indexing_suite<std::vector<double> >())
        ;
}

Here's the output of VS2017:

1>test.cpp
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/vector_indexing_suite.hpp(176): warning C4267: '+=': conversion from 'size_t' to 'long', possible loss of data
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/vector_indexing_suite.hpp(170): note: while compiling class template member function 'unsigned __int64 boost::python::vector_indexing_suite<std::vector<double,std::allocator<_Ty>>,false,boost::python::detail::final_vector_derived_policies<Container,false>>::convert_index(Container &,PyObject *)'
1>        with
1>        [
1>            _Ty=double,
1>            Container=std::vector<double,std::allocator<double>>
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/indexing_suite.hpp(261): note: see reference to function template instantiation 'unsigned __int64 boost::python::vector_indexing_suite<std::vector<double,std::allocator<_Ty>>,false,boost::python::detail::final_vector_derived_policies<Container,false>>::convert_index(Container &,PyObject *)' being compiled
1>        with
1>        [
1>            _Ty=double,
1>            Container=std::vector<double,std::allocator<double>>
1>        ]
1>C:\Users\Cyril\dev\test.cpp(9): note: see reference to class template instantiation 'boost::python::vector_indexing_suite<std::vector<double,std::allocator<_Ty>>,false,boost::python::detail::final_vector_derived_policies<Container,false>>' being compiled
1>        with
1>        [
1>            _Ty=double,
1>            Container=std::vector<double,std::allocator<double>>
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(54): note: see reference to class template instantiation 'boost::arg<9>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(53): note: see reference to class template instantiation 'boost::arg<8>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(52): note: see reference to class template instantiation 'boost::arg<7>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(51): note: see reference to class template instantiation 'boost::arg<6>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(50): note: see reference to class template instantiation 'boost::arg<5>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(49): note: see reference to class template instantiation 'boost::arg<4>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(48): note: see reference to class template instantiation 'boost::arg<3>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(47): note: see reference to class template instantiation 'boost::arg<2>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/bind/placeholders.hpp(46): note: see reference to class template instantiation 'boost::arg<1>' being compiled
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/detail/indexing_suite_detail.hpp(605): warning C4267: '+=': conversion from 'size_t' to 'long', possible loss of data
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/detail/indexing_suite_detail.hpp(590): note: while compiling class template member function 'void boost::python::detail::slice_helper<Container,DerivedPolicies,boost::python::detail::no_proxy_helper<Container,DerivedPolicies,boost::python::detail::container_element<Container,Index,DerivedPolicies>,Index>,Data,Index>::base_get_slice_data(Container &,PySliceObject *,Index &,Index &)'
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>,
1>            Index=unsigned __int64,
1>            Data=double
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/detail/indexing_suite_detail.hpp(695): note: see reference to function template instantiation 'void boost::python::detail::slice_helper<Container,DerivedPolicies,boost::python::detail::no_proxy_helper<Container,DerivedPolicies,boost::python::detail::container_element<Container,Index,DerivedPolicies>,Index>,Data,Index>::base_get_slice_data(Container &,PySliceObject *,Index &,Index &)' being compiled
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>,
1>            Index=unsigned __int64,
1>            Data=double
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/indexing_suite.hpp(256): note: see reference to class template instantiation 'boost::python::detail::slice_helper<Container,DerivedPolicies,boost::python::detail::no_proxy_helper<Container,DerivedPolicies,boost::python::detail::container_element<Container,Index,DerivedPolicies>,Index>,Data,Index>' being compiled
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>,
1>            Index=unsigned __int64,
1>            Data=double
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/indexing_suite.hpp(253): note: while compiling class template member function 'void boost::python::indexing_suite<Container,DerivedPolicies,false,false,double,unsigned __int64,double>::base_delete_item(Container &,PyObject *)'
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/indexing_suite.hpp(186): note: see reference to function template instantiation 'void boost::python::indexing_suite<Container,DerivedPolicies,false,false,double,unsigned __int64,double>::base_delete_item(Container &,PyObject *)' being compiled
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/vector_indexing_suite.hpp(50): note: see reference to class template instantiation 'boost::python::indexing_suite<Container,DerivedPolicies,false,false,double,unsigned __int64,double>' being compiled
1>        with
1>        [
1>            Container=std::vector<double,std::allocator<double>>,
1>            DerivedPolicies=boost::python::detail::final_vector_derived_policies<std::vector<double,std::allocator<double>>,false>
1>        ]
1>C:\ThirdParty\1.8.0\win64-vc14\boost\include\boost-1_63\boost/python/suite/indexing/detail/indexing_suite_detail.hpp(619): warning C4267: '+=': conversion from 'size_t' to 'long', possible loss of data

I'm using Boost 1.63, VisualStudio 2017 15.5.4.

主要语言
C++
星标
537
派生
223
平均合并
11 小时 22 分钟
30 天内合并 PR
2

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

boostorg/python 的其他 Issue

查看 boostorg/python 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。