[PATCH] PR 7776: Warn about if ("abc" < "xyz") ...
Daniel Jacobowitz
drow@false.org
Sun Jun 5 17:59:00 GMT 2005
On Sun, Jun 05, 2005 at 10:42:15AM -0600, Roger Sayle wrote:
> + if (TREE_CODE_CLASS (code) == tcc_comparison
> + && (TREE_CODE (arg1.value) == STRING_CST
> + || TREE_CODE (arg2.value) == STRING_CST))
> + warning (OPT_Wstring_literal_comparison,
> + "comparison with string literal");
> +
> unsigned_conversion_warning (result.value, arg1.value);
> unsigned_conversion_warning (result.value, arg2.value);
> overflow_warning (result.value);
>
So, all comparisons in which either side is a string literal. I don't
think that's a good choice. What about this:
if ("foo" == NULL)
Maybe there are no other interesting special cases besides == 0 and !=
0.
--
Daniel Jacobowitz
CodeSourcery, LLC
More information about the Gcc-patches
mailing list