public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26383]  New: -O3 and -Wall produce spurious warnings about builtin string functions
@ 2006-02-20 16:39 andrew dot m dot roberts at tesco dot net
  2006-02-20 16:42 ` [Bug c/26383] " andrew dot m dot roberts at tesco dot net
  2006-02-20 17:17 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: andrew dot m dot roberts at tesco dot net @ 2006-02-20 16:39 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1817 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/26383] -O3 and -Wall produce spurious warnings about builtin string functions
  2006-02-20 16:39 [Bug c/26383] New: -O3 and -Wall produce spurious warnings about builtin string functions andrew dot m dot roberts at tesco dot net
@ 2006-02-20 16:42 ` andrew dot m dot roberts at tesco dot net
  2006-02-20 17:17 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: andrew dot m dot roberts at tesco dot net @ 2006-02-20 16:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from andrew dot m dot roberts at tesco dot net  2006-02-20 16:41 -------
Created an attachment (id=10880)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10880&action=view)
gcc -v -save-temps -O3 -Wall output


-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/26383] -O3 and -Wall produce spurious warnings about builtin string functions
  2006-02-20 16:39 [Bug c/26383] New: -O3 and -Wall produce spurious warnings about builtin string functions andrew dot m dot roberts at tesco dot net
  2006-02-20 16:42 ` [Bug c/26383] " andrew dot m dot roberts at tesco dot net
@ 2006-02-20 17:17 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-20 17:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-02-20 17:17 -------
This is really  a glibc bug as far as I can tell.
Lets look into what glibc exands the string functions to:
 i=__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (data) &&
__builtin_constant_p (s) && (__s1_len = strlen (data), __s2_len = strlen (s),
(!((size_t)(const void *)((data) + 1) - (size_t)(const void *)(data) == 1) ||
__s1_len >= 4) && (!((size_t)(const void *)((s) + 1) - (size_t)(const void
*)(s) == 1) || __s2_len >= 4)) ? __builtin_strcmp (data, s) :
(__builtin_constant_p (data) && ((size_t)(const void *)((data) + 1) -
(size_t)(const void *)(data) == 1) && (__s1_len = strlen (data), __s1_len < 4)
? (__builtin_constant_p (s) && ((size_t)(const void *)((s) + 1) -
(size_t)(const void *)(s) == 1) ? __builtin_strcmp (data, s) : (__extension__
({ __const unsigned char *__s2 = (__const unsigned char *) (__const char *)
(s); register int __result = (((__const unsigned char *) (__const char *)
(data))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result =
(((__const unsigned char *) (__const char *) (data))[1] - __s2[1]); if
(__s1_len > 1 && __result == 0) { __result = (((__const unsigned char *)
(__const char *) (data))[2] - __s2[2]); if (__s1_len > 2 && __result == 0)
__result = (((__const unsigned char *) (__const char *) (data))[3] - __s2[3]);
} } __result; }))) : (__builtin_constant_p (s) && ((size_t)(const void *)((s) +
1) - (size_t)(const void *)(s) == 1) && (__s2_len = strlen (s), __s2_len < 4) ?
(__builtin_constant_p (data) && ((size_t)(const void *)((data) + 1) -
(size_t)(const void *)(data) == 1) ? __builtin_strcmp (data, s) :
(__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *)
(__const char *) (data); register int __result = __s1[0] - ((__const unsigned
char *) (__const char *) (s))[0]; if (__s2_len > 0 && __result == 0) { __result
= (__s1[1] - ((__const unsigned char *) (__const char *) (s))[1]); if (__s2_len
> 1 && __result == 0) { __result = (__s1[2] - ((__const unsigned char *)
(__const char *) (s))[2]); if (__s2_len > 2 && __result == 0) __result =
(__s1[3] - ((__const unsigned char *) (__const char *) (s))[3]); } } __result;
}))) : __builtin_strcmp (data, s)))); });

Yes that mess.

This is not a gcc bug, there is nothing GCC can do better.
Anyways with ppc-darwin, I only get the following warnings (not using the
preprocessed source):
t.c:8: warning: pointer targets in passing argument 1 of 'strcpy' differ in
signedness
t.c:9: warning: pointer targets in passing argument 1 of 'strcmp' differ in
signedness

So this is a bug in the glibc headers which exposed the other warnings.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-20 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-20 16:39 [Bug c/26383] New: -O3 and -Wall produce spurious warnings about builtin string functions andrew dot m dot roberts at tesco dot net
2006-02-20 16:42 ` [Bug c/26383] " andrew dot m dot roberts at tesco dot net
2006-02-20 17:17 ` pinskia at gcc dot gnu dot org

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).