This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16367] New: No worning with -ansi -pedantic about passing unsigned char * to strcmp if using -O2
- From: "sampo dot nurmentaus at movial dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jul 2004 07:06:28 -0000
- Subject: [Bug c/16367] New: No worning with -ansi -pedantic about passing unsigned char * to strcmp if using -O2
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc -v -save-temps -ansi -pedantic -g -O2 -Wall -Wmissing-prototypes
-Wmissing-declarations -Werror -MT keke.lo -MD -MP -MF -fPIC -DPIC -c keke.c
-o keke.o
does not issue a warning if I try to pass unsigned char * to strcmp that takes
char * If i change -O2 to -O0 the warning is shown.
-fstrict-aliasing/-fno-strict-aliasing has no effect on this. This takes place
when a call to a function returning unsigned char * from a struct member is
given as an argument to strcmp as in example below:
(no precompiler output given, since I have no idea how to
attach it in bugzilla!)
#include <string.h>
struct mopo {
unsigned char *keke;
};
unsigned char *kake(struct mopo *m);
int main(int argc, char **argv)
{
struct mopo m;
m.keke=(unsigned char *)argv[0];
strcmp(kake(&m),"keke");
return 0;
}
unsigned char *kake( struct mopo *m )
{
return m->keke;
}
thanks in advance,
Sampo Nurmentaus
--
Summary: No worning with -ansi -pedantic about passing unsigned
char * to strcmp if using -O2
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sampo dot nurmentaus at movial dot fi
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386 gnu linux
GCC host triplet: i386 gnu linux
GCC target triplet: i386 gnu linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16367