Boost C++ Libraries: Ticket #5186: uuid process_characters problem https://svn.boost.org/trac10/ticket/5186 <p> In boost/uuid/name_generator.hpp, there is the method: </p> <blockquote> <p> void process_characters(char_type const*const characters, size_t count) { </p> <blockquote> <p> BOOST_ASSERT(sizeof(uint32_t) &gt;= sizeof(char_type)); </p> </blockquote> </blockquote> <blockquote> <blockquote> <p> for (size_t i=0; i&lt;count; i++) { </p> <blockquote> <p> uint32_t c = characters[i]; sha.process_byte( (c &gt;&gt; 0) &amp;&amp; 0xFF ); sha.process_byte( (c &gt;&gt; 8) &amp;&amp; 0xFF ); sha.process_byte( (c &gt;&gt; 16) &amp;&amp; 0xFF ); sha.process_byte( (c &gt;&gt; 24) &amp;&amp; 0xFF ); </p> </blockquote> <p> } </p> </blockquote> <p> } </p> </blockquote> <p> The usage of ' &amp;&amp; 0xFF ' means that all these lines just evaluate to '1', meaning all this really does is create a hash of the length of the string, except if there are any embedded NULLs in the strings. </p> <p> There is an obvious fix, which is to change &amp;&amp; to &amp;. However, this would obviously change the strings which are generated. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5186 Trac 1.4.3 Marshall Clow Mon, 14 Feb 2011 15:15:15 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5186#comment:1 https://svn.boost.org/trac10/ticket/5186#comment:1 <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">duplicate</span> </li> </ul> <p> This is a duplicate of ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5145" title="#5145: Patches: Fixed warning: use of logical &amp;&amp; with constant operand; switch to ... (closed: fixed)">#5145</a> </p> Ticket