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: Martin Dalecki <dalecki at cs dot net dot pl>
- Subject: Re: C: Proposal: Warning using char* a; if(a == "")
- From: David Starner <dvdeug at x8b4e53cd dot dhcp dot okstate dot edu>
- Date: Fri, 5 Nov 1999 22:10:58 -0600
- Cc: gcc at gcc dot gnu dot org
- References: <199911060115.RAA11419@atrus.synopsys.com> <3823A154.45FD4107@cs.net.pl>
- Reply-To: dstarner98 at aasaa dot ofe dot org
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