GNU bug report logs -
#15634
coreutils-8.21 possible coding error ?
Previous Next
Reported by: David Binderman <dcb314 <at> hotmail.com>
Date: Thu, 17 Oct 2013 07:55:02 UTC
Severity: normal
Tags: notabug
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
David Binderman wrote:
> [lib/sig2str.c:329]: (warning) Logical conjunction always evaluates to false: signum <= -1 && signum>= 0.
This seems to be cppcheck complaining about a test that is needed
on other platforms, but which the compiler can optimize away on
your platform. We can safely ignore this diagnostic as well:
it's perfectly OK, and in fact nice, to have code that a compiler
can optimize away on some platforms.
> if (!print_database < argc)
>
> Some round brackets might help clarify the code
>
> if ((!print_database) < argc)
The code's pretty clear as-is, since there
are spaces around the " < " but not after the "!".
I think I'd rather ignore this diagnostic; in general,
"Comparison of a boolean value using relational operator (<,>, <= or>=)"
is bogus. There's nothing wrong with comparing Booleans.
If you have two Booleans A and B, and want to write "A implies B",
it's often faster and (once you get used to it) more comprehensible
to write "A <= B", instead of the "!A | B" that cppcheck would
seem to require. (Admittedly I'd rather write "A -> B"
but this is C we're talking about....)
Eric already covered the other two diagnostics you mentioned.
This bug report was last modified 6 years and 283 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.