Opened 9 years ago
Closed 9 years ago
#9596 closed Patches (fixed)
"logical ‘and’ of mutually exclusive tests is always false" error in random/linear_congruential.hpp
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | To Be Determined | Component: | random |
Version: | Boost 1.55.0 | Severity: | Optimization |
Keywords: | Cc: |
Description
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 <= 0 && _x != 0) be equal to if(_x < 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.
Change History (2)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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 <= 0 && x != 0 was sufficient to avoid a warning, but apparently that's no longer the case.