-
Notifications
You must be signed in to change notification settings - Fork 673
Open
Description
I have a warning that I get when compiling code that uses boost::beast. This happens only on msys2 when compiling with g++ (my version is 15.1.0). This warning doesn't really make much sense as it doesn't even show what code specifically leads to it:
mtlro@MAIN-NOTE MINGW64 /d/work-pps/backtest-engine/vs
$ nice -20 cmake --build $BUILD
[3/4] Building CXX object CMakeFiles/test.dir/src/test/WebSocketTest.cpp.obj
In file included from D:/work-pps/boost_1_89_0/boost/asio/ip/basic_resolver.hpp:32,
from D:/work-pps/boost_1_89_0/boost/asio/ip/tcp.hpp:25,
from D:/work-pps/boost_1_89_0/boost/beast/core/tcp_stream.hpp:17,
from D:/work-pps/boost_1_89_0/boost/beast/core.hpp:49,
from D:/work-pps/boost_1_89_0/boost/beast.hpp:15,
from D:/work-pps/backtest-engine/src/test/WebSocketTest.cpp:1:
D:/work-pps/boost_1_89_0/boost/asio/ip/basic_resolver_results.hpp: In static member function 'static boost::asio::ip::basic_resolver_results<InternetProtocol> boost::asio::ip::basic_resolver_results<InternetProtocol>::create(boost::asio::detail::addrinfo_type*, const std::string&, const std::string&) [with InternetProtocol = boost::asio::ip::tcp]':
D:/work-pps/boost_1_89_0/boost/asio/ip/basic_resolver_results.hpp:139:15: warning: 'void* memcpy(void*, const void*, size_t)' forming offset [28, 128] is out of the bounds [0, 28] of object 'endpoint' with type 'boost::asio::ip::tcp::endpoint' {aka 'boost::asio::ip::basic_endpoint<boost::asio::ip::tcp>'} [-Warray-bounds=]
139 | memcpy(endpoint.data(), address_info->ai_addr,
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140 | address_info->ai_addrlen);
| ~~~~~~~~~~~~~~~~~~~~~~~~~
D:/work-pps/boost_1_89_0/boost/asio/ip/basic_resolver_results.hpp:137:45: note: 'endpoint' declared here
137 | typename InternetProtocol::endpoint endpoint;
| ^~~~~~~~
Here's the trimmed code that produces this warning:
#include <boost/beast.hpp>
namespace net = boost::asio;
namespace ssl = net::ssl;
namespace beast = boost::beast;
namespace http = beast::http;
namespace websocket = beast::websocket;
void test()
{
using tcp = net::ip::tcp;
net::io_context ioc_ws;
tcp::resolver resolver_ws{ioc_ws};
std::unique_ptr<websocket::stream<tcp::socket>> ws;
ws = std::make_unique<websocket::stream<tcp::socket>>(ioc_ws);
auto results = resolver_ws.resolve("127.0.0.1", "80");
net::connect(ws->next_layer(), results.begin(), results.end());
ws->handshake("127.0.0.1", "/ws");
}
I use boost 1.89. I had the same warning with older versions as well.
Metadata
Metadata
Assignees
Labels
No labels