Boost C++ Libraries: Ticket #9596: "logical ‘and’ of mutually exclusive tests is always false" error in random/linear_congruential.hpp https://svn.boost.org/trac10/ticket/9596 <p> There is a line in random/linear_congruential.hpp at line 136 which seems to work, but may be a bit wrong. It may definitely be my somewhat small knowledge of how the compiler works, but shouldn't this: if(_x &lt;= 0 &amp;&amp; _x != 0) be equal to if(_x &lt; 0). This line throws an error with the -Werror flag set in gcc 4.7.2: with "logical ‘and’ of mutually exclusive tests is always false [-Werror=logical-op]". These are not mutually exclusive, so the compiler may be wrong, but the question still remains if this could be done better. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9596 Trac 1.4.3 Steven Watanabe Mon, 10 Mar 2014 23:14:56 GMT <link>https://svn.boost.org/trac10/ticket/9596#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9596#comment:1</guid> <description> <p> The tests are mutually exclusive for unsigned types. The problem is that the expression is always false for unsigned type, but is needed for signed types. When I wrote it, using _x &lt;= 0 &amp;&amp; x != 0 was sufficient to avoid a warning, but apparently that's no longer the case. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Tue, 11 Mar 2014 19:24:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9596#comment:2 https://svn.boost.org/trac10/ticket/9596#comment:2 <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> Fixed in <a class="ext-link" href="http://github.com/boostorg/random/commit/00c250421adeac15352dec64bda736e8f02b8844"><span class="icon">​</span>http://github.com/boostorg/random/commit/00c250421adeac15352dec64bda736e8f02b8844</a>. </p> Ticket