Convergence problems with Intel's 8.0 C++ compiler

Felix E. Klee felix.klee.gmp at
Mon Mar 1 18:49:27 CET 2004

On Sun, 29 Feb 2004 06:15:54 +1000 Kevin Ryde wrote:
> I might try to put a note about this in the manual.  I imagine various
> templated numerical add-ons like "complex" might suffer from this sort
> of issue.

FYI, I got another answer to my question in comp.lang.c++.moderated. 
It is attached below. The essence is that, according to the standard, 
the complex (and valarray) template should not be used with mpf_class 
because, when creating an instance of mpf_class, then
    using a copy constructor
doesn't necessarily give the same result as
    using a default constructor followed by an assignment.
Hm, I guess I should really take the time and read all that is relevant
from section 26 of the standard...

Maybe some kind of mpf_complex_class could be included in future 
releases, or made available as an add on? In any case, such a class
shouldn't be too hard to write.


PS: To contact me off list don't reply but send mail to "felix.klee" at
the domain "". Otherwise your email to me might get automatically

Answer from Gabriel Dos Reis to my question in comp.lang.c++.moderated:

Felix E. Klee" < at> writes:

| BTW, I already looked at the standard and found that the post condition
|      real() == re && imag() == im
| needs to satisfied (in the case of the GMP library, due to the design of
| mpf_class::operator==(), both implementations satisfy this condition).
| But, isn't this condition somewhat broken? For example, for any
| conceivable implementation of complex, there seems to be a type with a
| weird operator==() or a weird copy constructor, that violates that
| condition.

If you have a fancy class that has weird operator==() or a weird
copy constructor, then you'll get a weird behaviour.

While from a formal point of view, it is unspecified what you get when
instantiating a std::complex<> with something that is not float,
double nor long double, I would expect that you don't try to feed that
class template with fancy classes with "weird" behaviour.

>From a practical point of view, I would expect that if the type you
use to instantiate std::complex<> satisfies the requirement in

  26.1  Numeric type requirements

  1  The complex and valarray components are parameterized by the type
     of information they contain and the manipulate.  A C++ program
     shall instantiate these components only with a type T that
     satisfies  the following requirements:
     -- If T is a class, its assignment operator, copy and default
        constructors, and destructor shall correspond to each other in
        the following sense: Initialization of raw storage using the
        default constructor, followed by assignment, is semantically
        equivalent to initialization of raw storage using the copy
        constructor. Destruction of an object, followed by initialization
        of its raw storage using the copy constructor, is semantically
        equivalent to assignment to the original object.

>From your description, the class mpf_class fails that test.

More information about the gmp-discuss mailing list