[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fwd: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit
From: |
Bruno Haible |
Subject: |
Re: Fwd: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit |
Date: |
Wed, 26 Sep 2007 12:18:51 +0200 |
User-agent: |
KMail/1.5.4 |
Cristian Baboi wrote:
> I don't know why, but otherwise here is what I get:
>
> PASS: 33 620782629
> PASS:
> 236
> 808464933
> PASS: 337
> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808660517
> PASS: 290
> 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000808464677
> Segmentation fault <----------- see ?
>
> This are the compile warnings from gcc:
> vasprintf.c: In function `vasprintf':
> vasprintf.c:125: warning: passing arg 3 of `int_vasprintf' from
> incompatible pointer type
>
> g++ said:
> vasprintf.c: In function `int int_vasprintf(char**, const char*,
> __va_list_tag (*)[1])':
> vasprintf.c:115: error: invalid conversion from `void*' to `char*'
> vasprintf.c: In function `int vasprintf(char**, const char*,
> __va_list_tag*)':
> vasprintf.c:125: error: cannot convert `__va_list_tag**' to `__va_list_tag
> (*)[1]' for argument `3' to `int int_vasprintf(char**, const char*,
> __va_list_tag (*)[1])'
Thank you for these error messages. They make it clear what happened:
Taking the address of a function parameter of array type does not yield
a pointer to this array type.
I'm applying this fix.
2007-09-26 Bruno Haible <address@hidden>
* lib/vasprintf.c (int_vasprintf): Pass the args as a va_list,
not as a 'va_list *'. Needed on x86_64-linux, where va_list is an
array type: taking the address of a parameter of type va_list does
not yield a 'va_list *'. We have to assume that platforms where
passing a va_list by reference is useful (either because va_end is
not a no-op or because sizeof(va_list) is large) have already defined
va_list to an array type; no need to try to enforce passing by
reference.
Reported by Cristian Baboi <address@hidden>.
--- lib/vasprintf.c 25 Sep 2007 00:24:18 -0000 1.6
+++ lib/vasprintf.c 26 Sep 2007 10:12:58 -0000
@@ -32,7 +32,7 @@
#endif
static int
-int_vasprintf (char **result, const char *format, va_list *args)
+int_vasprintf (char **result, const char *format, va_list args)
{
const char *p = format;
/* Add one to make sure that it is never zero, which might cause malloc
@@ -40,7 +40,7 @@
size_t total_width = strlen (format) + 1;
va_list ap;
- va_copy (ap, *args);
+ va_copy (ap, args);
while (*p != '\0')
{
if (*p++ == '%')
@@ -115,7 +115,7 @@
#endif
*result = malloc (total_width);
if (*result != NULL)
- return vsprintf (*result, format, *args);
+ return vsprintf (*result, format, args);
else
return -1;
}
@@ -123,7 +123,7 @@
int
vasprintf (char **result, const char *format, va_list args)
{
- return int_vasprintf (result, format, &args);
+ return int_vasprintf (result, format, args);
}
int