Clarification on testsuite 'runnable/testmath.d'

Daniel Green venix1 at gmail.com
Fri Jan 13 22:51:37 PST 2012


I've been working on fixing GDC/MinGW's runtime support.  I ran across 
the following and was hoping to get a clarification on what DMD does 
differently than GDC.

void testexp()
{
     printf("exp(3.0) = %Lg, %Lg\n", exp(3.0), E * E * E);
     assert(equals(exp(3.0), E * E * E, 16));
}

Of interest is exp(3.0).  GDC matches exp(3.0) to double exp(double). 
This causes problems with printf due to %Lg wanting a real but only 
receiving a double.

Looking at the D specification for overloading functions.
     1. no match
     2. match with implicit conversions
     3. match with conversion to const
     4. exact match


The specification doesn't indicate what levels are better.  I would 
guess 4 is the best since an exact match should take precedence.
However, that results in GDC matching exp(3.0) to double exp(double).

How does DMD match exp(3.0)?

Could it possibly be a typo?  For 32-bit this test passes because the 
printf doesn't segfault, it's only  noticeable with 64-bit since it 
segfaults.


More information about the Digitalmars-d mailing list