Opened 4 years ago

#10539 new Bugs

Type error in detail::socket_ops::host_to_network_short

Reported by: Louis-Michel Veilleux <louismichel.veilleux@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost Release Branch Severity: Optimization
Keywords: Cc:


Type of result local variable should be u_short_type. Causes compilation warning C4244 with MSVC ( "possible loss of data" ).

u_short_type host_to_network_short(u_short_type value)
  u_long_type result;
  unsigned char* result_p = reinterpret_cast<unsigned char*>(&result);
  result_p[0] = static_cast<unsigned char>((value >> 8) & 0xFF);
  result_p[1] = static_cast<unsigned char>(value & 0xFF);
  return result;
  return htons(value);

Change History (0)

Note: See TracTickets for help on using tickets.