This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[tbrowder@home.com] libc/2173: libc compatibility with C++



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);				      \
     }))





>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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]