Dear all, Currently Wextra warns about a pointer compared against integer zero with <, <=, >, or >=. This warning is not available in C++ (the documentation does not say this) and it is implemented in gcc/c-typeck.c (build_binary_op) in this manner:
else if (code0 == POINTER_TYPE && null_pointer_constant_p (orig_op1)) { result_type = type0; if (pedantic || extra_warnings) pedwarn ("ordered comparison of pointer with integer zero"); } else if (code1 == POINTER_TYPE && null_pointer_constant_p (orig_op0)) { result_type = type1; if (pedantic) pedwarn ("ordered comparison of pointer with integer zero"); } That is, given int *p and -Wextra, the above code warns for p < 0 but not for 0 > p. Given -pedantic, we warn for both situations. This is also the only warning activated by both pedantic and -Wextra. Taking into account the above, is there a reason for this? For me, the best would be to NOT enable the warning for Wextra, so I don't need to come up with a name for this warning flag. Otherwise, we would have to document that the warning is enabled by both pedantic and Wextra, so a user won't be surprised when the warning does not go away by using the Wno-* form just because pedantic is enabled. Please, I would appreciate your comments on this, so I can submit a patch implementing whichever is thought to be the best approach. Cheers, Manuel.