Skip to content

Intel C++ Compiler XE 12.1.x warnings  #4

@mabrarov

Description

@mabrarov

Environment:

  1. Windows 7 SP1 Pro.
  2. Intel C++ Compiler XE 12.1.5.344 build 20120612.
  3. Asio from Boost C++ Libraries 1.51.0.
  4. Warning level: Level4 (/W4).

Warnings:

1>..\..\..\..\boost_1_51_0\boost/asio/detail/impl/socket_ops.ipp(2787): warning #181: argument is incompatible with corresponding format string conversion
1>          sprintf(serv, "%u", ntohs(port));
1>                              ^
1>  
1>..\..\..\..\boost_1_51_0\boost/asio/detail/impl/socket_ops.ipp(2812): warning #181: argument is incompatible with corresponding format string conversion
1>            sprintf(serv, "%u", ntohs(port));
1>                                ^
1>
1>..\..\..\..\boost_1_51_0\boost/asio/detail/impl/win_static_mutex.ipp(48): warning #1786: function "swprintf(__wchar_t *, const __wchar_t *, ...)" (declared at line 85 of "c:\Program Files\Microsoft Visual Studio 10.0\VC\include\swprintf.inl") was declared deprecated ("swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.")
1>      swprintf(mutex_name,
1>      ^
1>   
1>..\..\..\..\boost_1_51_0\boost/asio/detail/winsock_init.hpp(78): warning #2415: variable "boost::asio::detail::winsock_init_instance" of static storage duration was declared but never referenced
1>    static const winsock_init<>& winsock_init_instance = winsock_init<>(false);
1>                                 ^
1>  
1>..\..\..\..\boost_1_51_0\boost/asio/error.hpp(244): warning #2415: variable "boost::asio::error::system_category" of static storage duration was declared but never referenced
1>    static const boost::system::error_category& system_category
1>                                                ^
1>  
1>..\..\..\..\boost_1_51_0\boost/asio/error.hpp(246): warning #2415: variable "boost::asio::error::netdb_category" of static storage duration was declared but never referenced
1>    static const boost::system::error_category& netdb_category
1>                                                ^
1>  
1>..\..\..\..\boost_1_51_0\boost/asio/error.hpp(248): warning #2415: variable "boost::asio::error::addrinfo_category" of static storage duration was declared but never referenced
1>    static const boost::system::error_category& addrinfo_category
1>                                                ^
1>  
1>..\..\..\..\boost_1_51_0\boost/asio/error.hpp(250): warning #2415: variable "boost::asio::error::misc_category" of static storage duration was declared but never referenced
1>    static const boost::system::error_category& misc_category
1>                                                ^
1>  
1>..\..\..\..\boost_1_51_0\boost/system/error_code.hpp(214): warning #2415: variable "boost::system::posix_category" of static storage duration was declared but never referenced
1>        static const error_category &  posix_category = generic_category();
1>                                       ^
1>  
1>..\..\..\..\boost_1_51_0\boost/system/error_code.hpp(215): warning #2415: variable "boost::system::errno_ecat" of static storage duration was declared but never referenced
1>        static const error_category &  errno_ecat     = generic_category();
1>                                       ^
1>  
1>..\..\..\..\boost_1_51_0\boost/system/error_code.hpp(216): warning #2415: variable "boost::system::native_ecat" of static storage duration was declared but never referenced
1>        static const error_category &  native_ecat    = system_category();
1>                                       ^

Proposed solution for warning #181:

--- boost/asio/detail/impl/socket_ops.ipp   Пн июл 23 15:03:31 2012
+++ boost/asio/detail/impl/socket_ops.ipp   Вс сен  2 15:55:52 2012
@@ -2782,9 +2782,9 @@
         return ec = boost::asio::error::no_buffer_space;
       }
 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
-      sprintf_s(serv, servlen, "%u", ntohs(port));
+      sprintf_s(serv, servlen, "%u", static_cast<unsigned>(ntohs(port)));
 #else
-      sprintf(serv, "%u", ntohs(port));
+      sprintf(serv, "%u", static_cast<unsigned>(ntohs(port)));
 #endif
     }
     else
@@ -2807,9 +2807,9 @@
           return ec = boost::asio::error::no_buffer_space;
         }
 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(UNDER_CE)
-        sprintf_s(serv, servlen, "%u", ntohs(port));
+        sprintf_s(serv, servlen, "%u", static_cast<unsigned>(ntohs(port)));
 #else
-        sprintf(serv, "%u", ntohs(port));
+        sprintf(serv, "%u", static_cast<unsigned>(ntohs(port)));
 #endif
       }
 #if defined(BOOST_HAS_THREADS) && defined(BOOST_HAS_PTHREADS) \

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions