Использование boost 1.4.2 asio в приложении C++ и получение предупреждений о компиляторе Linux, я не grok.boost asio ssl stream socket компиляция проблема
еще здесь?
Приложение, в котором я работаю, нуждается в «сокете», который может быть сокет ssl или обычный сокет tcp, поэтому мы скрываем специфику за шаблоном «сокет», который принимает либо класс сокета ssl, либо tcp socket class as параметр шаблона - ниже приведен код класса ssl.
Приложение работает правильно, без какой-либо оптимизации; проблема заключается в том, когда я компилирую в linux g ++ 4.4.1 и включаю оптимизацию на -02 или выше, флаг -fstrict-aliasing включается. Компиляция приводит к строгим предупреждениям алиасов вдоль линий: «предупреждение: разыменования типа каламбурил указатель будет нарушать правила строгого сглаживания» везде я разыменовать _psock (например _psock-> рукопожатия)
Я хотел бы знать, почему это предупреждение выпускается, и это указывает на проблему проектирования ...
class socket_ssl_cli
{
public:
typedef ba::ssl::stream<ba::ip::tcp::socket> socket_type;
socket_ssl_cli(ba::io_service& io_svc, SocketConfig & sockcfg)
: _io_svc(io_svc)
, _ctxt(_io_svc, ba::ssl::context::tlsv1)
, _psock(0)
{
try {
// the one and only ssl context
// hardcoded for test, but get these values from config
_ctxt.set_options(ba::ssl::context::default_workarounds |
ba::ssl::context::verify_none);
_psock = new socket_type(_io_svc, _ctxt);
} catch (bs::system_error & x) {
throw std::runtime_error(x.code().message());
}
}
~socket_ssl_cli()
{
if (_psock) {
bs::error_code ec;
close_socket(ec);
delete _psock;
}
}
socket_type & raw_socket() { return *_psock; }
void setup(bs::error_code & ec)
{
_psock->handshake(ba::ssl::stream_base::client, ec);
}
void close_socket(bs::error_code & ec)
{
// shut down ssl, then shutdown socket, then close socket
_psock->shutdown(ec);
_psock->lowest_layer().shutdown(ba::socket_base::shutdown_both, ec);
_psock->lowest_layer().close(ec);
}
private:
ba::io_service & _io_svc;
ba::ssl::context _ctxt;
socket_type * _psock;
};
все мучительный выход компиляции с -02 включен, что приводит к -fstrict-Aliasing
../. ./../../third-party/boost/1.42.0/boost/function/function_base.hpp : 321: предупреждение: разыменованный тип-караульный указатель нарушит правила строгого сглаживания ../../../../third-party/boost/1.42.0/boost/function/function_base.hpp:325: предупреждение : разыменованный тип-караульный указатель нарушит правила строгого сглаживания ../../../../third-party/boost/1.42.0/boost/function/function_base.hpp: В статической функции-члене «статическая пустота» boost :: detail :: function :: functor_manager_common :: manage_small (const boost :: detail :: function :: function_buffer &, boost :: detail :: function :: function_buffer &, boost :: detail :: function :: functor_manager_operation_type) [с помощью Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>>>>>>]: ../../../../third-party/boost/ 1.42.0/boost/function/function_base.hpp: 360: создается из статического void boost :: detail :: function :: functor_manager :: manager (const boost :: detail :: function :: function_buffer &, boost :: detail :: function :: function_buffer &, boost :: detail :: function :: functor_manager_operation_type, mpl _ :: true_) [with Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi: : list1>> *>>>] ' ../../../../third-party/boost/1.42.0/boost/function/function_base.hpp:406: создается экземпляр из «static void boost: : detail :: function :: functor_manager :: manager (const boost :: detail :: function :: function_buffer &, boost :: detail :: function :: function_buffer &, boost :: detail :: function :: functor_manager_operation_type, boost: : detail :: function :: function_obj_tag) [с Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>> *>>>] ' ../../../. ./third-party/boost/1.42.0/boost/function/function_base.hpp:434: экземпляр из 'static void boost :: detail :: function :: functor_manager :: manage (const boost :: detail :: function: : функц ion_buffer &, boost :: detail :: function :: function_buffer &, boost :: detail :: function :: functor_manager_operation_type) [с Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>> *>>>] ' ../../../../third-party/boost/1.42.0/boost/function/function_template.hpp:913: экземпляр из' void boost :: function0 :: assign_to (Functor) [с Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>>>>>>, R = int] ' ../../../../ сторонний/boost/1.42.0/boost/function/function_template.hpp: 722: экземпляр из функции boost :: function0 :: function0 (Functor, typeename boost :: enable_if_c :: type) [с помощью Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>> *>>>, R = int] ' ../../../../third-party/boost/1.42.0/boost/функция/function_template.hpp: 1064: экземпляр из функции boost :: function :: function (Functor, typename boost :: enable_if_c :: type) [с помощью Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>> *>>>, R = int] ' ../../../../third-party/boost/1.42.0/boost/function/function_template.hpp:1105: экземпляр из' typename boost :: enable_if_c &> :: type boost :: function :: operator = (Functor) [with Functor = boost :: _ bi :: bind_t>>>, boost :: _ bi :: list1>>>>>>, R = int] ' ../../../../third-party/boost/1.42.0/boost/asio/ssl/detail/openssl_operation.hpp:134: экземпляр из' boost :: asio :: ssl :: detail :: openssl_operation :: openssl_operation (boost :: asio :: ssl :: detail :: ssl_primitive_func, поток &, boost :: asio :: ssl :: detail :: net_buffer &, SSL *, BIO *) [с Stream = boost :: asio :: basic_stream_socket>] ' ../../../../third-party/boost/1.42. 0/boost/asio/ssl/detail/openssl_stream_service.hpp: 510: создается из «boost :: system :: error_code boost :: asio :: ssl :: detail :: openssl_stream_service :: handshake (boost :: asio :: ssl :: detail :: openssl_stream_service :: impl_struct * &, Stream &, boost :: asio :: ssl :: stream_base :: handshake_type, boost :: system :: error_code &) [с потоком = boost :: asio :: basic_stream_socket> ] ' ../../../../third-party/boost/1.42.0/boost/asio/ssl/stream_service.hpp:100: создается из системы boost :: system :: error_code boost :: asio :: ssl :: stream_service :: handshake (boost :: asio :: ssl :: detail :: openssl_stream_service :: impl_struct * &, поток &, boost :: asio :: ssl :: stream_base :: handshake_type, boost :: system :: error_code &) [с потоком = boost :: asio :: basic_stream_socket>] ' .. /../../../third-party/boost/1.42.0/boost/asio/ssl/stream.hpp:207: создан из системы boost :: system :: error_code boost :: asio :: ssl: : stream :: handshake (boost :: asio :: ssl :: stream_base :: handshake_type, boost :: system :: error_code &) [с потоком = boost :: asio :: basic_stream_socket>, Service = boost :: asio :: :: stream_service SSL] ../sockets/socket_ssl_cli.h:45: инстанцирован здесь