This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C: Proposal: Warning using char* a; if(a == "")



> 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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]