Boost C++ Libraries: Ticket #13337: io_service::stop() behavior on MSVC contradicts documentation https://svn.boost.org/trac10/ticket/13337 <p> The io_service::stop() documentation says: </p> <blockquote class="citation"> <blockquote> <p> [...] All invocations of this run() or run_one() member functions should return as soon as possible [...] </p> </blockquote> </blockquote> <p> This is the behavior observed on GCC but not on MSVC. </p> <p> Reproducer code: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/asio.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;thread&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="o">::</span><span class="n">chrono_literals</span><span class="p">;</span> <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">boost</span><span class="o">::</span><span class="n">asio</span><span class="o">::</span><span class="n">io_service</span> <span class="n">s</span><span class="p">;</span> <span class="n">s</span><span class="p">.</span><span class="n">post</span><span class="p">([]</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span><span class="mi">5</span><span class="n">ms</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;1</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="p">});</span> <span class="n">s</span><span class="p">.</span><span class="n">post</span><span class="p">([]</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span><span class="mi">5</span><span class="n">ms</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;2</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="p">});</span> <span class="n">s</span><span class="p">.</span><span class="n">post</span><span class="p">([]</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span><span class="mi">5</span><span class="n">ms</span><span class="p">);</span> <span class="n">std</span><span class="o">::</span><span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;3</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="p">});</span> <span class="n">std</span><span class="o">::</span><span class="kr">thread</span> <span class="n">th</span><span class="p">([</span><span class="o">&amp;</span><span class="p">]</span> <span class="p">{</span> <span class="n">s</span><span class="p">.</span><span class="n">run</span><span class="p">();</span> <span class="p">});</span> <span class="n">std</span><span class="o">::</span><span class="n">this_thread</span><span class="o">::</span><span class="n">sleep_for</span><span class="p">(</span><span class="mi">1</span><span class="n">ms</span><span class="p">);</span> <span class="n">s</span><span class="p">.</span><span class="n">stop</span><span class="p">();</span> <span class="n">th</span><span class="p">.</span><span class="n">join</span><span class="p">();</span> <span class="p">}</span> </pre></div></div><p> This prints "1" on <a class="ext-link" href="https://wandbox.org/permlink/N02wy78yFGX1eJRl"><span class="icon">​</span>GCC</a> but "1 2 3" on <a class="ext-link" href="http://rextester.com/FHNW43260"><span class="icon">​</span>MSVC</a> </p> <p> This bug was concretized by an Stack Overflow user while he investigated <a class="new ticket" href="https://svn.boost.org/trac10/ticket/13317" title="#13317: Bugs: io_service behaviour difference between ubuntu and msvc-14 (new)">#13317</a>. See <a class="ext-link" href="https://stackoverflow.com/a/47733861/4999407"><span class="icon">​</span>his answer</a> for more information. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13337 Trac 1.4.3 Diego Barrios Romero <eldruin@…> Tue, 12 Dec 2017 11:10:39 GMT component changed; owner set https://svn.boost.org/trac10/ticket/13337#comment:1 https://svn.boost.org/trac10/ticket/13337#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">chris_kohlhoff</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">asio</span> </li> </ul> <p> Select the correct boost component </p> Ticket