Boost C++ Libraries: Ticket #2534: Removing gcc warning https://svn.boost.org/trac10/ticket/2534 <p> The function </p> <blockquote> <p> boost::asio::detail::pipe_select_interrupter::interupt() </p> </blockquote> <p> in &lt;boost/asio/detail/pipe_select_interrupter.hpp&gt; produces the following warning in gcc 4.3.2 / glibc 2.8 when compiled with -O1 or higher. The warning occurs even without any -W options. </p> <blockquote> <p> ./boost/asio/detail/pipe_select_interrupter.hpp:75: </p> <blockquote> <p> warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result </p> </blockquote> </blockquote> <p> As the message implies, gcc issues this warning whenever a function declared with <span class="underline">attribute</span>((warn_unused_result)); it appears that gcc implicitly places this attribute on ::write as the glibc header doesn't contain it. A short test case is: </p> <blockquote> <p> #include &lt;unistd.h&gt; int main() { ::write(1, 0, 0); } </p> </blockquote> <p> To suppress the warning, the function interupt() function can be altered as follows: </p> <blockquote> <p> #include &lt;boost/concept_check.hpp&gt; </p> </blockquote> <blockquote> <p> void interrupt() { </p> <blockquote> <p> char byte = 0; ignore_unused_variable_warning( ::write(write_descriptor_, &amp;byte, 1) ); </p> </blockquote> <p> } </p> </blockquote> <p> Is there any chance of making a change along these lines? </p> <p> Apologies if this is a know issue: a quick search of the mailing list didn't turn anything up. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2534 Trac 1.4.3 peter _dot_ schneider _dot_ 127 _at_ googlemail _dot_ com Tue, 09 Dec 2008 00:45:56 GMT severity changed; keywords set https://svn.boost.org/trac10/ticket/2534#comment:1 https://svn.boost.org/trac10/ticket/2534#comment:1 <ul> <li><strong>keywords</strong> gcc warning added </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Cosmetic</span> </li> </ul> <p> "confirm" bjam-output of my project: </p> <pre class="wiki">...patience... ...found 1105 targets... ...updating 3 targets... gcc.compile.c++ bin/gcc-4.3.2/release/serialsap.o In file included from /usr/local/include/boost-1_37/boost/asio/detail/select_interrupter.hpp:24, from /usr/local/include/boost-1_37/boost/asio/detail/epoll_reactor.hpp:42, from /usr/local/include/boost-1_37/boost/asio/impl/io_service.ipp:25, from /usr/local/include/boost-1_37/boost/asio/io_service.hpp:550, from /usr/local/include/boost-1_37/boost/asio/basic_io_object.hpp:20, from /usr/local/include/boost-1_37/boost/asio/basic_socket.hpp:24, from /usr/local/include/boost-1_37/boost/asio/basic_datagram_socket.hpp:25, from /usr/local/include/boost-1_37/boost/asio.hpp:20, from serialsap.h:8, from serialsap.cpp:1: /usr/local/include/boost-1_37/boost/asio/detail/eventfd_select_interrupter.hpp: In member function ‘void boost::asio::detail::eventfd_select_interrupter::interrupt()’: /usr/local/include/boost-1_37/boost/asio/detail/eventfd_select_interrupter.hpp:89: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result In file included from /usr/local/include/boost-1_37/boost/asio/detail/select_interrupter.hpp:25, from /usr/local/include/boost-1_37/boost/asio/detail/epoll_reactor.hpp:42, from /usr/local/include/boost-1_37/boost/asio/impl/io_service.ipp:25, from /usr/local/include/boost-1_37/boost/asio/io_service.hpp:550, from /usr/local/include/boost-1_37/boost/asio/basic_io_object.hpp:20, from /usr/local/include/boost-1_37/boost/asio/basic_socket.hpp:24, from /usr/local/include/boost-1_37/boost/asio/basic_datagram_socket.hpp:25, from /usr/local/include/boost-1_37/boost/asio.hpp:20, from serialsap.h:8, from serialsap.cpp:1: /usr/local/include/boost-1_37/boost/asio/detail/pipe_select_interrupter.hpp: In member function ‘void boost::asio::detail::pipe_select_interrupter::interrupt()’: /usr/local/include/boost-1_37/boost/asio/detail/pipe_select_interrupter.hpp:75: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result gcc.compile.c++ bin/gcc-4.3.2/release/protocol.o gcc.link bin/gcc-4.3.2/release/foo ...updated 3 targets... </pre><p> Only occurs on release-mode, debug-mode works fine. </p> <pre class="wiki">gcc -v Using built-in specs. Target: x86_64-linux-gnu ... et=x86_64-linux-gnu Thread model: posix gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu11) </pre><p> not important but would be nice to fix.. </p> <p> MfG </p> Ticket anonymous Wed, 07 Jan 2009 12:44:35 GMT <link>https://svn.boost.org/trac10/ticket/2534#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2534#comment:2</guid> <description> <p> This happens also in boost_1_37_0/boost/asio/detail/eventfd_select_interrupter.hpp. </p> <p> Is the workaround suggested here safe? The warning is there for a good reason, I presume. </p> <p> These are my details: </p> <blockquote class="citation"> <p> uname -a </p> </blockquote> <p> Linux compilator 2.6.27-9-server <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> SMP Thu Nov 20 22:53:41 UTC 2008 i686 GNU/Linux </p> <pre class="wiki">g++ -c -o myxxxfile.o -O3 -I../boost_1_37_0/ -MP -MD myxxxfile.cpp In file included from ../boost_1_37_0/boost/asio/detail/select_interrupter.hpp:24, from ../boost_1_37_0/boost/asio/detail/epoll_reactor.hpp:42, from ../boost_1_37_0/boost/asio/impl/io_service.ipp:25, from ../boost_1_37_0/boost/asio/io_service.hpp:550, from ../boost_1_37_0/boost/asio/basic_io_object.hpp:20, from ../boost_1_37_0/boost/asio/basic_socket.hpp:24, from ../boost_1_37_0/boost/asio/basic_datagram_socket.hpp:25, from ../boost_1_37_0/boost/asio.hpp:20, from stdafx.h:22, from myxxxfile.cpp:1: ../boost_1_37_0/boost/asio/detail/eventfd_select_interrupter.hpp: In member function 'void boost::asio::detail::eventfd_select_interrupter::interrupt()': ../boost_1_37_0/boost/asio/detail/eventfd_select_interrupter.hpp:89: warning: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sun, 01 Feb 2009 12:28:13 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2534#comment:3 https://svn.boost.org/trac10/ticket/2534#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/50946" title="Suppress unused result warning. Fixes #2534. ">[50946]</a>) Suppress unused result warning. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2534" title="#2534: Bugs: Removing gcc warning (closed: fixed)">#2534</a>. </p> Ticket chris_kohlhoff Wed, 04 Feb 2009 06:22:51 GMT <link>https://svn.boost.org/trac10/ticket/2534#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2534#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51004" title="Merged revisions 50943-50950,50961-50964,50987 via svnmerge from ...">[51004]</a>) Merged revisions 50943-50950,50961-50964,50987 via svnmerge from <a class="ext-link" href="https://svn.boost.org/svn/boost/trunk"><span class="icon">​</span>https://svn.boost.org/svn/boost/trunk</a> </p> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50943" title="Need to specify socket lib to link correctly on QNX. Fixes #2504. ">r50943</a> | chris_kohlhoff | 2009-02-01 22:37:18 +1100 (Sun, 01 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Need to specify socket lib to link correctly on QNX. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2504" title="#2504: Patches: asio tests need to be linked to socket lib on QNX 6 (closed: fixed)">#2504</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50944" title="Use correct size for IP_MULTICAST_LOOP option on QNX. Fixes #2530. ">r50944</a> | chris_kohlhoff | 2009-02-01 22:42:09 +1100 (Sun, 01 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Use correct size for IP_MULTICAST_LOOP option on QNX. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2530" title="#2530: Patches: Size of data for IP_MULTICAST_LOOP socket option incorrect on QNX 6.4.0 (closed: fixed)">#2530</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50945" title="Improve warning message when _WIN32_WINNT is not correctly defined. ...">r50945</a> | chris_kohlhoff | 2009-02-01 22:57:01 +1100 (Sun, 01 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Improve warning message when _WIN32_WINNT is not correctly defined. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2541" title="#2541: Bugs: Asio not working on windows due to QueueUserAPC missing in global namespace (closed: fixed)">#2541</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50946" title="Suppress unused result warning. Fixes #2534. ">r50946</a> | chris_kohlhoff | 2009-02-01 23:28:12 +1100 (Sun, 01 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Suppress unused result warning. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2534" title="#2534: Bugs: Removing gcc warning (closed: fixed)">#2534</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50947" title="Ensure arguments to windows::overlapped_ptr::complete() are passed ...">r50947</a> | chris_kohlhoff | 2009-02-01 23:41:01 +1100 (Sun, 01 Feb 2009) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Ensure arguments to windows::overlapped_ptr::complete() are passed through to the completion handler. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2614" title="#2614: Bugs: asio overlapped_ptr::complete ignores arguments (closed: fixed)">#2614</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50948" title="Add include of &lt;cstring&gt; to fix a compile error on Solaris 10. Fixes ...">r50948</a> | chris_kohlhoff | 2009-02-01 23:50:08 +1100 (Sun, 01 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add include of &lt;cstring&gt; to fix a compile error on Solaris 10. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2607" title="#2607: Bugs: asio compilation error on solaris 10 (closed: fixed)">#2607</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50949" title="Clear the last error following a successful Windows API call, since ...">r50949</a> | chris_kohlhoff | 2009-02-02 00:25:05 +1100 (Mon, 02 Feb 2009) | 3 lines </p> </blockquote> <p> </p> <blockquote> <p> Clear the last error following a successful Windows API call, since some socket providers may leave last error set even when the call succeeds. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50950" title="Fix errors in SSL overview and add a note about handshaking. Fixes ...">r50950</a> | chris_kohlhoff | 2009-02-02 00:42:33 +1100 (Mon, 02 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix errors in SSL overview and add a note about handshaking. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2617" title="#2617: Bugs: SSL overview documentation issues (closed: fixed)">#2617</a> and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2619" title="#2619: Bugs: SSL overview documentation: handshake missing (closed: fixed)">#2619</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50961" title="Use a pipe if eventfd is not supported at runtime. Fixes #2683. ">r50961</a> | chris_kohlhoff | 2009-02-02 17:18:59 +1100 (Mon, 02 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Use a pipe if eventfd is not supported at runtime. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2683" title="#2683: Bugs: eventfd_select_interrupter: Function not implemented (closed: fixed)">#2683</a>. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50962" title="Add link to asio wiki. ">r50962</a> | chris_kohlhoff | 2009-02-02 18:06:00 +1100 (Mon, 02 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Add link to asio wiki. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50963" title="Use the workaround syntax for specifying a return type with ...">r50963</a> | chris_kohlhoff | 2009-02-02 20:36:11 +1100 (Mon, 02 Feb 2009) | 4 lines </p> </blockquote> <p> </p> <blockquote> <p> Use the workaround syntax for specifying a return type with boost::bind. Needed for the SSL support to work on some older compilers (in particular, g++ 3.4.5 as used with MinGW). </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50964" title="Update asio version number. ">r50964</a> | chris_kohlhoff | 2009-02-02 20:37:10 +1100 (Mon, 02 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Update asio version number. </p> </blockquote> <p> ........ </p> <blockquote> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/50987" title="Fix generated documentation where the overloads of a function have ...">r50987</a> | chris_kohlhoff | 2009-02-03 22:00:39 +1100 (Tue, 03 Feb 2009) | 2 lines </p> </blockquote> <p> </p> <blockquote> <p> Fix generated documentation where the overloads of a function have different brief descriptions. </p> </blockquote> <p> ........ </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 29 Apr 2009 03:25:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2534#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2534#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2534#comment:2" title="Comment 2">anonymous</a>: </p> <blockquote class="citation"> <p> Is the workaround suggested here safe? The warning is there for a good reason, I presume. </p> </blockquote> <p> AFAIK, the result of a write() should always be checked: the socket or NFS may have gone down, the drive could be full, etc. If this case is just debugging information, or some kind of optional output, ignoring the status might be fine, but IMHO it needs comments to explicitly explain why it is safe. </p> </description> <category>Ticket</category> </item> </channel> </rss>