gcc version 4.1.0 20060219 (prerelease) produces spurious warnings when
used with -Wall and -O3 together. Previous released versions haven't had this
behaviour. It appears to be issuing multiple warnings when string functions are
inlined using the __builtin_ versions eg __builtin_strcmp. For example:

test-strcmp.c:9: warning: pointer targets in passing argument 1 of ‘strlen’
differ in signedness
test-strcmp.c:9: warning: pointer targets in passing argument 1 of
‘__builtin_strcmp’ differ in signedness
test-strcmp.c:9: warning: pointer targets in passing argument 1 of
‘__builtin_strcmp’ differ in signedness
test-strcmp.c:9: warning: pointer targets in passing argument 1 of
‘__builtin_strcmp’ differ in signedness

The inital warning about strlen is great, the rest is just about GCC internals
and confusing. Here is a code snippet:

#include <string.h>

int main(void)
{
        int i;
        const char *s="Hello";
        unsigned char data[40];
        strcpy(data, s);
        i=strcmp(data, s);
        return 0;
}
this will show the problem when built with the prerelease version of gcc (4.1.0
20060219 (prerelease)) as follows:
gcc -O3 -Wall -o test test.c

I'll attach the build log from gcc -v -save-temps later.

Thanks

Andrew Roberts


-- 
           Summary: -O3 and -Wall produce spurious warnings about builtin
                    string functions
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot m dot roberts at tesco dot net
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26383

Reply via email to