boostorg / boostorg/program_options

validation_error implicit copy/move constructor

Đang mở
#147 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
136
Fork
117
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

We had a number of program options , most `uint*_t` and one additional that is a `vector` using `mutlitoken` ) that began erroring. This was working, but post updates to boost 1.88.0 (prior 1.75.0) + clang 19.1.7, it now produces an error. We have opted to throw some push/pops around this in our code right now to suppress the issue but would like to address it with a more appropriate fix. Included below is the warning for one of the numeric options. We did not investigate these as much as we did the arguments_map ( https://github.com/boostorg/program_options/issues/146 ), but would believe this one is better handled by adding default constructors (this might even be a case where `BOOST_DEFAULTED_FUNCTION` should be updated) as nothing jumps out as being a pointer where special handling may be required but would like those with more knowledge of the library to weigh in.

```
In file included from /home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options.hpp:15:
In file included from /home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/options_description.hpp:12:
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/errors.hpp:383:34: error: definition of implicit copy constructor for 'validation_error' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated-copy-with-dtor]
383 | BOOST_DEFAULTED_FUNCTION(~validation_error() BOOST_NOEXCEPT_OR_NOTHROW, {})
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/throw_exception/include/boost/throw_exception.hpp:97:41: note: in implicit copy constructor for 'boost::program_options::validation_error' first required here
97 | explicit wrapexcept( E const & e ): E( e )
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/throw_exception/include/boost/throw_exception.hpp:165:11: note: in instantiation of member function 'boost::wrapexcept::wrapexcept' requested here
165 | throw wrapexcept( e );
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/detail/value_semantic.hpp:62:24: note: in instantiation of function template specialization 'boost::throw_exception' requested here
62 | boost::throw_exception(validation_error(validation_error::multiple_values_not_allowed));
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/detail/value_semantic.hpp:90:48: note: in instantiation of function template specialization 'boost::program_options::validators::get_single_string' requested here
90 | std::basic_string s(validators::get_single_string(xs));
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/detail/value_semantic.hpp:184:13: note: in instantiation of function template specialization 'boost::program_options::validate' requested here
184 | validate(value_store, new_tokens, static_cast(nullptr), 0);
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/value_semantic.hpp:189:9: note: in instantiation of member function 'boost::program_options::typed_value::xparse' requested here
189 | typed_value(T* store_to)
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/detail/value_semantic.hpp:199:33: note: in instantiation of member function 'boost::program_options::typed_value::typed_value' requested here
199 | typed_value* r = new typed_value(v);
| ^
/home/user/bitbucket/app/apps/app_name/src/main.cpp:111:49: note: in instantiation of function template specialization 'boost::program_options::value' requested here
111 | ("listen_port", boost::program_options::value(&opt_listen_port)->value_name("LISTEN_PORT")->required(),"Port to listen on")
| ^
```

https://quuxplusone.github.io/blog/2023/05/05/deprecated-copy-with-dtor/
https://stackoverflow.com/a/51864979

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu trong errors.hpp tại validation_error và kiểm tra cách destructor cùng các hàm thành viên đặc biệt của nó tương tác với BOOST_DEFAULTED_FUNCTION. Sau đó, lần theo chi tiết quá trình khởi tạo sao chép trong throw_exception.hpp và đường đi của lời gọi trong detail/value_semantic.hpp. Công việc được xem là hoàn tất khi lỗi deprecated-copy-with-dtor đã được báo cáo được xử lý mà caller không cần tắt chẩn đoán.

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

Đánh giá

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

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.