This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/5113] New: -Wconversion is not quiet in /usr/include/bits/string2.h
- From: "christian dot iseli at licr dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 5 Oct 2007 09:24:22 -0000
- Subject: [Bug libc/5113] New: -Wconversion is not quiet in /usr/include/bits/string2.h
- Reply-to: sourceware-bugzilla at sourceware dot org
When compiling code that uses the strdup function using the -Wconversion
compiler switch, the compiler will warn:
warning: passing argument 1 of 'calloc' with different width due to prototype
warning: passing argument 2 of 'calloc' with different width due to prototype
This is due to inlines from the header /usr/include/bits/string2.h that contains
code like:
# define __strdup(s) \
(__extension__ (__builtin_constant_p (s) && __string2_1bptr_p (s) \
? (((__const char *) (s))[0] == '\0' \
? (char *) calloc (1, 1) \
: ({ size_t __len = strlen (s) + 1; \
char *__retval = (char *) malloc (__len); \
if (__retval != NULL) \
__retval = (char *) memcpy (__retval, s, __len); \
__retval; })) \
: __strdup (s)))
The warning would go away if the calloc call was written:
calloc ((size_t) 1, (size_t) 1)
or using some suffix, but the suffix probably depends on being 32 or 64 bits...
There seem to be other cases of calling calloc (1, 1) in the header.
--
Summary: -Wconversion is not quiet in /usr/include/bits/string2.h
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: christian dot iseli at licr dot org
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=5113
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.