This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[tbrowder@home.com] libc/2173: libc compatibility with C++
- To: Ulrich Drepper <drepper at cygnus dot com>
- Subject: [tbrowder@home.com] libc/2173: libc compatibility with C++
- From: Andreas Jaeger <aj at suse dot de>
- Date: 02 Apr 2001 09:05:49 +0200
- Cc: libc-alpha at sources dot redhat dot com, tbrowder at home dot com
Here's a patch for the bug report. Ok to commit?
Andreas
2001-04-02 Andreas Jaeger <aj@suse.de>
* string/string.h (strndupa): Add cast for C++ conformance.
(strdupa): Likewise.
Fixes PR libc/2173, reported by tbrowder@home.com.
============================================================
Index: string/string.h
--- string/string.h 2001/02/06 18:27:12 1.79
+++ string/string.h 2001/04/02 07:05:29
@@ -135,7 +135,7 @@
({ \
__const char *__old = (s); \
size_t __len = strlen (__old) + 1; \
- char *__new = __builtin_alloca (__len); \
+ char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
}))
@@ -145,7 +145,7 @@
({ \
__const char *__old = (s); \
size_t __len = strnlen (__old, (n)); \
- char *__new = __builtin_alloca (__len + 1); \
+ char *__new = (char *) __builtin_alloca (__len + 1); \
__new[__len] = '\0'; \
(char *) memcpy (__new, __old, __len); \
}))
- To: libc-gnats at gnu dot org, gnats-admin at gnu dot org
- Subject: libc/2173: libc compatibility with C++
- From: tbrowder at home dot com
- Date: Sat, 31 Mar 2001 07:26:31 -0500
- Reply-To: tbrowder at home dot com
- Xref: gee.suse.de mail.gnats-libc-bugs:5902
>Number: 2173
>Category: libc
>Synopsis: libc compatibility with C++
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: libc-gnats
>State: open
>Quarter:
>Keywords:
>Class: change-request
>Submitter-Id: gnatsweb
>Arrival-Date: Sat Mar 31 07:26:31 -0500 2001
>Cases:
>Originator: Tom Browder
>Release:
>Organization:
Mygnus
>Environment:
Red Hat 7.0 and 7.0+ beta distributions on i686; gcc 2.95.3.
>Description:
Attempting to use the GNU extension functions strdupa or strndupa (macros defined in string.h) in a C++ program yields following error:
"ANSI C++ forbids implicit conversion from 'void *' in initialization."
>How-To-Repeat:
Use strdupa or strndupa in a simple C++ program.
>Fix:
In file "string.h," for functions strdupa and strndupa, add a cast to char* in front of the call to __builtin_alloca.
>Unformatted:
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj