GMP 5.1.1 make check fail on Solaris 11

ken mays maybird1776 at
Fri Feb 15 17:31:01 CET 2013

Hi Marc,

$uname -srm
SunOS 5.11 i86pc

$gcc -v
kmays cxx ( gcc -v
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: ../gcc-4.6.2/configure --prefix=/usr/gcc/4.6 --libdir=/usr/gcc/
4.6/lib --libexecdir=/usr/gcc/4.6/lib --mandir=/usr/gcc/4.6/share/man --infodir=
/usr/gcc/4.6/info --with-build-time-tools=/usr/sfw --with-as=/usr/sfw/bin/gas --
with-gnu-as --with-ld=/usr/bin/ld --without-gnu-ld --enable-languages=c,c++,fort
ran,objc --enable-shared --disable-static --enable-decimal-float --with-gmp=/usr
/gnu --with-mpfr=/usr/gnu --with-mpc=/usr/gnu --with-libiconv-prefix=/usr/gnu -e
Thread model: posix
gcc version 4.6.2 (GCC)

$cd gmp-5.1.1/tests/cxx
$ ./ken (Note: The ken 'executeable' is your provided test program)

terminate called after throwing an instance of 'std::invalid_argument'
Abort (core dumped)

My diagnosis:
Yes, the specific GCC build I used does not handle C++ exceptions 'properly' in this case. I've use another
GCC build (4.6.2, same version) built for C++ exception handling and all make check cxx tests passed 100%. This can be
duplicated also by using the GCC 4.7.2 compiler (, 4.7.2,REV=2013.01.19) available from

Now if I use Solaris Studio 12.1:
cc: Sun C 5.10 SunOS_i386 Patch 142363-03 2009/12/03

CC: Sun C++ 5.10 SunOS_i386 128229-03 2009/11/05

Sun Studio 12.1 passed 100% with gmp-5.1.1 make check tests with C code only.
Sun Studio 12.1 required a patch for gmp-5.1.1, when using --disable-static --enable-cxx (i.e. C++ code) due to: 

$ gmp-5.1.1: ./configure  ABI=64  --disable-static --enable-cxx --disable-assembly --prefix=/usr/local

/bin/sh ../libtool --tag=CXX   --mode=compile /opt/sunstudio12.1/bin/CC -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I..    -fast -libmieee -KPIC -m64 -c -o limits.lo

libtool: compile:  /opt/sunstudio12.1/bin/CC -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMPXX -I.. -fast -libmieee -KPIC -m64 -c  -KPIC -DPIC -o .libs/limits.o

"../gmpxx.h", line 1520: Error: Could not find a match for std::swap<std::_charT, std::_Traits, std::_Allocator>(__mpz_struct, __mpz_struct) needed in __gmp_expr<__mpz_struct[1], __mpz_struct[1]>::swap(__gmp_expr<__mpz_struct[1], __mpz_struct[1]>&).

"../gmpxx.h", line 1714: Error: Could not find a match for std::swap<std::_charT, std::_Traits, std::_Allocator>(__mpq_struct, __mpq_struct) needed in __gmp_expr<__mpq_struct[1], __mpq_struct[1]>::swap(__gmp_expr<__mpq_struct[1], __mpq_struct[1]>&).

"../gmpxx.h", line 1935: Error: Could not find a match for std::swap<std::_charT, std::_Traits, std::_Allocator>(__mpf_struct, __mpf_struct) needed in __gmp_expr<__mpf_struct[1], __mpf_struct[1]>::swap(__gmp_expr<__mpf_struct[1], __mpf_struct[1]>&).

3 Error(s) detected.
gmake[2]: *** [limits.lo] Error 1

Needed for succession of:
/bin/sh ../libtool --tag=CXX   --mode=link /opt/sunstudio12.1/bin/CC  -fast -libmieee -KPIC -m64   -o  isfuns.lo ismpf.lo ismpq.lo ismpz.lo ismpznw.lo limits.lo osdoprnti.lo osfuns.lo osmpf.lo osmpq.lo osmpz.lo

Seems like everything else compiles fine, once that issue is resolve and make check passes all C/C++ tests!! If anyone wants to
send me a more formal patch or resolution, I'll retest the build with my configuration.

Otherwise, the gmp 5.1.1 builds 100% using Sun Studio 12.1 or GCC 4.6.2 with Oracle Solaris 11. The assembler for Sun Studio 12.1
may be outdated for today's C++ compiler needs, so I suggest people use Oracle Solaris Studio 12.3 - if possible. I used --disable-assembly as a workaround.

Suggestion (RFE):
I'd ask development if during 'configure' if proper C++ exception handling is not detected, a possible warning message alerts the maintainer. Then, the maintainer can chose to either 'fix' the compiler issue or ignore the message!
Hope that helps,
Ken Mays

 From: Marc Glisse <marc.glisse at>
To: "gmp-bugs at" <gmp-bugs at> 
Cc: ken mays <maybird1776 at> 
Sent: Thursday, February 14, 2013 4:33 PM
Subject: Re: GMP 5.1.1 make check fail on Solaris 11
On Thu, 14 Feb 2013, Marc Glisse wrote:

> Please check on trivial examples that exceptions indeed are broken.


could you confirm if the following program also fails to run on your system, using the same compiler and the options from CXXFLAGS? You can replace the content of one of the tests in tests/cxx with this and re-run make check to make sure you compile it in the same conditions.

#include <stdexcept>

inline void
throw_expr ()
  throw std::invalid_argument ("Test");

using namespace std;

main ()
  catch (invalid_argument) { }

More information about the gmp-bugs mailing list