[Patch] Another fix for GMP 4.2.1 with Sun Studio 11

Albert Chin gmp-bugs at mlists.thewrittenword.com
Sat Aug 12 00:22:25 CEST 2006


On Fri, Jul 21, 2006 at 05:38:18PM +0200, Matthias Koeppe wrote:
> I am sending another patch for GMP 4.2.1 with --enable-cxx, using the
> Sun Studio 11 compilers.  Make check failed like this:
> 
> /solapplic/sun-studio-11/SUNWspro/bin/CC -DHAVE_CONFIG_H -I. -I. -I../.. -I../.. -I../../tests    -xO4 -xarch=v8plus -xchip=ultra3 -c -o t-assign.o t-assign.cc
> "../../gmpxx.h", line 1389: Error: Formal argument 3 of type extern "C" void(*)(void*,unsigned)* in call to __gmp_get_memory_functions(extern "C" void*(*)(unsigned)*, extern "C" void*(*)(void*,unsigned,unsigned)*, extern "C" void(*)(void*,unsigned)*) is being passed void(*)(void*,unsigned)*.
> "../../gmpxx.h", line 1390: Warning: The variable freefunc has not yet been assigned a value.
> 1 Error(s) and 1 Warning(s) detected.
> 
> 
> 
> diff -c -r /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/gmpxx.h gmp-4.2.1/gmpxx.h
> *** /home/mkoeppe/w/latte/distro/gmp-4.2.1.orig/gmpxx.h	Sat Apr  8 21:15:38 2006
> --- gmp-4.2.1/gmpxx.h	Fri Jul 21 17:04:03 2006
> ***************
> *** 1379,1391 ****
>   /* this is much the same as gmp_allocated_string in gmp-impl.h
>      since gmp-impl.h is not publicly available, I redefine it here
>      I use a different name to avoid possible clashes */
>   struct __gmp_alloc_cstring
>   {
>     char *str;
>     __gmp_alloc_cstring(char *s) { str = s; }
>     ~__gmp_alloc_cstring()
>     {
> !     void (*freefunc) (void *, size_t);
>       mp_get_memory_functions (NULL, NULL, &freefunc);
>       (*freefunc) (str, std::strlen(str)+1);
>     }
> --- 1379,1395 ----
>   /* this is much the same as gmp_allocated_string in gmp-impl.h
>      since gmp-impl.h is not publicly available, I redefine it here
>      I use a different name to avoid possible clashes */
> + extern "C" {
> +   typedef void (*__gmp_alloc_cstring_freefunc) (void *, size_t);
> + }
> + 
>   struct __gmp_alloc_cstring
>   {
>     char *str;
>     __gmp_alloc_cstring(char *s) { str = s; }
>     ~__gmp_alloc_cstring()
>     {
> !     __gmp_alloc_cstring_freefunc freefunc;
>       mp_get_memory_functions (NULL, NULL, &freefunc);
>       (*freefunc) (str, std::strlen(str)+1);
>     }

I think this is a bug in gmp.h. We had a similar issue with the HP-UX
11.23/IA C++ compiler for KDE:
  http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/f3bf25cc9d9c6a40/b8022e7424158041?lnk=st&q=&rnum=1&hl=en#b8022e7424158041

gmp.h should be patched to provide a typedef for the 3rd arg as you
did in gmpxx.h.

-- 
albert chin (china at thewrittenword.com)


More information about the gmp-bugs mailing list