FYI: quadmath.h's expq() crashes at runtime

[email protected] Sun, 6 Oct 2013 01:06:50 +1000
Newsgroups perl.win32.vanilla
Message-ID <E2BABFCCF3654FCC98EF025460E62384@OwnerPC311012>
Hi,

It's no big deal, but current Strawberry Perl 32-bit and 64-bit compilers 
create executables that crash when expq() is called.

Here's the minimalistic demo script:

####################
#include <quadmath.h>

int main (void) {
  __float128 r;

  r = expq(2.0Q);
  r = sqrtq(2.0Q);
  r = fabsq(2.0Q);
  r = sinq(2.0Q);
  r = logq(2.0Q);
  r = cosq(2.0Q);

  return 0;
}

####################

The resultant executable crashes when run, but remove the expq() call and 
there's no problem. (Link to -lquadmath when building the above program.)

It's not just MinGW64's gcc-4.6.3 compilers that are affected. I find the 
same with their 64-bit gcc-4.7.0, and 4.8.1 compilers. (I haven't tested any 
other MinGW64 compilers.)

I've also found that mingw.org's gcc-4.7.0 does *not* suffer this problem; 
nor does Ubuntu's gcc-4.6.3 ... so I guess I probably should report this to 
the mingw64 project.

BTW, the perl relevance here is that, because of this bug, Math::Float128 
crashes its test suite when expq() gets called. But I don't think that 
there's a high demand for this module, so I wouldn't be too concerned about 
that aspect.

Also of slight relevance to Strawberry Perl is the fact that 
c/lib/gcc/[whatever]-w64-mingw32/4.6.3 is not in $Config{libpth}.
As a consequence perl does not automatically find -lquadmath when the 
Math::Float128 Makefile.PL is run, and perl therefore removes the link. (The 
gcc linker can find -lquadmath without any help at all ... but it won't look 
for that library if perl has removed the link.)

Cheers,
Rob