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

Matthias Koeppe mkoeppe at mail.math.uni-magdeburg.de
Fri Jul 21 17:38:18 CEST 2006


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

-- 
Matthias Koeppe -- http://www.math.uni-magdeburg.de/~mkoeppe


More information about the gmp-bugs mailing list