GCC: Wmaybe-uninitialized in indexing_suite_detail

Đang mở
#516 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp, python
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu với include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp tại dòng 678 và tái hiện cảnh báo bằng ví dụ tối thiểu cùng lệnh GCC được cung cấp. Lần theo đường dẫn indexing_suite_detail vào container_utils.hpp để hiểu thao tác đọc chưa được khởi tạo được báo cáo. Công việc được xem là hoàn tất khi ví dụ biên dịch bằng GCC 15.2.1 mà không có cảnh báo này, đồng thời vẫn giữ nguyên hành vi lập chỉ mục vector.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Recent GCC versions (tested on g++ (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7) on Fedora 43 with Boost 1.83, but should not differ from newer Boost versions), when compiling this minimal working example:

#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
namespace py = boost::python;

BOOST_PYTHON_MODULE(Types) {
    py::class_<std::vector<std::string>>("StringVector").def(py::vector_indexing_suite<std::vector<std::string>>());
}

with this command line: g++ -shared -fPIC Types.cxx -Wextra -O2 -std=c++17 -I/usr/include/python3.14 -I/usr/include/boost - lboost_python314 -lpython3.14

throw Wmaybe-uninitialized:

In file included from /usr/include/c++/15/string:56,
                 from /usr/include/boost/assert/source_location.hpp:15,
                 from /usr/include/boost/exception/exception.hpp:9,
                 from /usr/include/boost/throw_exception.hpp:21,
                 from /usr/include/boost/function/detail/prologue.hpp:16,
                 from /usr/include/boost/function/function_template.hpp:13,
                 from /usr/include/boost/function/detail/maybe_include.hpp:15,
                 from /usr/include/boost/function/function0.hpp:11,
                 from /usr/include/boost/python/errors.hpp:13,
                 from /usr/include/boost/python/handle.hpp:11,
                 from /usr/include/boost/python/args_fwd.hpp:10,
                 from /usr/include/boost/python/args.hpp:10,
                 from /usr/include/boost/python.hpp:11,
                 from Types.cxx:1:
In member function ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/15/bits/basic_string.h:1176:20,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/15/bits/basic_string.h:617:20,
    inlined from ‘void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}; _Tp = std::__cxx11::basic_string<char>]’ at /usr/include/c++/15/bits/new_allocator.h:191:4,
    inlined from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}; _Tp = std::__cxx11::basic_string<char>]’ at /usr/include/c++/15/bits/alloc_traits.h:674:17,
    inlined from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]’ at /usr/include/c++/15/bits/stl_vector.h:1421:30,
    inlined from ‘void boost::python::container_utils::extend_container(Container&, boost::python::api::object) [with Container = std::vector<std::__cxx11::basic_string<char> >]’ at /usr/include/boost/python/suite/indexing/container_utils.hpp:44:40:
/usr/include/c++/15/bits/basic_string.h:1165:19: warning: ‘*(const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)((char*)&x + offsetof(boost::python::extract<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >,boost::python::extract<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::<unnamed>.boost::python::converter::extract_rvalue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::m_data.boost::python::converter::rvalue_from_python_data<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::<unnamed>.boost::python::converter::rvalue_from_python_storage<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::storage)).std::__cxx11::basic_string<char>::_M_string_length’ may be used uninitialized [-Wmaybe-uninitialized]
 1165 |         size_type __sz = _M_string_length;
      |                   ^~~~

This can be traced down to originating from this line in indexing_suite.hpp: https://github.com/boostorg/python/blob/105d64e8895ab893e5ac9e0380647d216c2cb8d9/include/boost/python/suite/indexing/detail/indexing_suite_detail.hpp#L678

Since this was not touched since Boost 1.83, I believe this to still be relevant. This seems unintentional and due to our project treating warnings as errors, for us this leads to a compile error.

Ngôn ngữ chính
C++
Star
540
Fork
224
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của boostorg/python

Tất cả issue của boostorg/python

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.