This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
- From: udbz at rz dot uni-karlsruhe dot de
- To: gcc-gnats at gcc dot gnu dot org
- Date: 30 Aug 2002 15:57:43 -0000
- Subject: c/7776: const char* p = "foo"; if (p == "foo") ... is compiled without warning!
- Reply-to: udbz at rz dot uni-karlsruhe dot de
>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: