On Mon, Nov 07, 2011 at 02:12:28PM +0100, Andreas Schwab wrote: > Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > > > I.e. we'll always have GREP_HEADER_AUTHOR = 0 and > > GREP_HEADER_COMMITTER = 1, we'll never have GREP_HEADER_AUTHOR = and > > GREP_HEADER_COMMITTER = <some int>. > > That is irrelevant. You can always assign -1 to an object of enumerated > type and the implicit conversion to the underlying type is fully > defined, no matter what type the compiler choses. Yes, but now you are getting into implementation-defined behavior, which is also something to avoid. IOW, I don't think it's wrong for a static analyzer to complain about: if (enum_with_only_positive_values < 0) just because you could say: enum_with_only_positive_values = -1; and it would work on _some_ platforms. That same static analyzer should be complaining about the second line, which is where the real potential bug is. If you want "-1" as an enumerated value, then add it to your enum definition and the compiler will do the right thing. It is perfectly fine to do: enum foo { a = -1, b, c }; ... if (foo < 0) ... and the static analyzer should not complain about the conditional there. -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html