public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
@ 2002-08-30 9:08 udbz
0 siblings, 0 replies; 3+ messages in thread
From: udbz @ 2002-08-30 9:08 UTC (permalink / raw)
To: gcc-gnats
>Number: 7776
>Category: c
>Synopsis: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Aug 30 09:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: udbz@rz.uni-karlsruhe.de
>Release: gcc-3.0.3
>Organization:
>Environment:
>Description:
The code construct below IMHO never makes sense and
should spill a warning.
It once caused me two months of work to discover this little
bug in the wine sources.
>How-To-Repeat:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, const char** argv)
{
const char * p = "Hello";
if (p == "Hello") {
fprintf(stderr, "1\n");
} else {
fprintf(stderr, "2\n");
}
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
@ 2002-08-30 11:06 Andrew Pinski
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Pinski @ 2002-08-30 11:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/7776; it has been noted by GNATS.
From: Andrew Pinski <pinskia@physics.uc.edu>
To: udbz@rz.uni-karlsruhe.de
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
Date: Fri, 30 Aug 2002 13:35:21 -0400
Are you asking for a warning so that the warning would suggest strcmp?
The code you provide does make sense to check for if the two occurrences
of "foo" are the same because the C standard does not say if they have
to be the same.
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
@ 2002-08-30 11:06 Peter Schlaile
0 siblings, 0 replies; 3+ messages in thread
From: Peter Schlaile @ 2002-08-30 11:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR c/7776; it has been noted by GNATS.
From: Peter Schlaile <udbz@rz.uni-karlsruhe.de>
To: Andrew Pinski <pinskia@physics.uc.edu>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c/7776: const char* p = "foo"; if (p == "foo") ... is compiled
without warning!
Date: Fri, 30 Aug 2002 19:57:40 +0200 (CEST)
Hi,
On Fri, 30 Aug 2002, Andrew Pinski wrote:
> Are you asking for a warning so that the warning would suggest strcmp?
That was the intended idea, yes!
> The code you provide does make sense to check for if the two occurrences
> of "foo" are the same because the C standard does not say if they have
> to be the same.
Yup!
Greetings,
Peter
---
Peter Schlaile *** eMail udbz@rz.uni-karlsruhe.de
So Linus, what are we doing tonight?
The same thing we do every night Tux. Try to take over the world!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-08-30 18:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-30 9:08 c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning! udbz
2002-08-30 11:06 Peter Schlaile
2002-08-30 11:06 Andrew Pinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).