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 == "")


On Sat, Nov 06, 1999 at 04:32:36AM +0100, Martin Dalecki wrote:
> Joe Buck wrote:
> > I do not believe that you can name me a platform where code of this form
> > is safe. Even if the compiler collapses matching strings in the same
> 
> PalmOS.

Okay. So the people working on the PalmOS (a miniscule number compared
to the Windows users, the Linux users, the *BSD users, the Solaris users)
can turn this off. Is it that unreasonable for gcc to offer warnings
for completely unportable, and usually wrong, code?

(Also, is it documented that that's the way PalmOS works? Stuff like that
can come around and bite you when they change it, and all the code that
made assumations break.)

> > > > Suggested text:
> > > > warning: direct comparison to string literal (did you mean to use `strcmp'?)
> > >
> > > Please add the following line maybe?:
> > >
> > >       Proceed to compile? [yes/no] (please type literally):
> > 
> > Why do you want that?  We're talking about adding a WARNING.  Of course
> > we proceed to compile the code!
> 
> The suggested text is offending. GCC users are not dumb and know what
> they want.

I've programmed using GNAT, and I've never been offended by it saying
"';' should be is" or things like that. Beats "syntax error" by a long
shot. It's not going to hurt expert programmers who will know that they 
should have used strcmp, and will help beginning programmers.

--
David Starner - dstarner98@aasaa.ofe.org


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