This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C: Proposal: Warning using char* a; if(a == "")
- To: dyoung at vviuh221 dot vvi dot com
- Subject: Re: C: Proposal: Warning using char* a; if(a == "")
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Fri, 5 Nov 99 19:37:39 PST
- Cc: gcc at gcc dot gnu dot org
> I think a better warning would be the factual one along the lines that
> root and "\\", being statically addressed evaluate to a constant expression
> which branches only one way. Something like:
>
> warning: conditional is constant
But the conditional is not necessarily constant; as has been pointed
out, there are odd cases (depending on the compiler collapsing repetitions
of the same string in the same compilation unit) where the test is
actually meaningful.
> But not to things like astring == bstring which makes sense to compare two
> variable string pointers.
No one is proposing warnings in any case except where one side is
a literal string (not a variable or const object).