Does it crash if you just call the function with no extra multiplication? <div><br><div class="gmail_quote">On Tue, May 15, 2012 at 7:44 PM, Stephan <span dir="ltr"><<a href="mailto:ss27@sanger.ac.uk" target="_blank">ss27@sanger.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am currently trying to call functions from the GNU Scientific Library (GSL) with my code, and I observed a very strange behaviour. The following test-program compiles, but generates a Segmentation fault when run.<br>
<br>
<br>
gsltest.d<br>
--------------------------<br>
import std.stdio;<br>
<br>
extern (C) double gsl_sf_hyperg_2F1(double a, double b, double c, double x);<br>
<br>
void main() {<br>
  double f = 0.0025;<br>
  // The following line causes a crash<br>
  auto ret = f * gsl_sf_hyperg_2F1(1.0, 10.0, 11.0, 1.0 - f / 0.025);<br>
<br>
  // The following line should be identical, but it does not cause the seg fault.<br>
  // auto ret = 0.0025 * gsl_sf_hyperg_2F1(1.0, 10.0, 11.0, 1.0 - f / 0.025);<br>
<br>
  writeln(ret);<br>
}<br>
---------------------------<br>
<br>
If you comment out the crashing line and comment in the line below, the program runs and returns 0.015681, which is the numerically correct result.<br>
<br>
To compile and run the code, I used the following command line:<br>
<br>
rdmd -L-L/opt/local/lib -L-lgsl -L-lgslcblas gsltest.d<br>
<br>
<br>
I tested this on Unix and Mac OS X. Can anyone reproduce the error and have an idea what is going on?<br>
<br>
Cheers,<br>
<br>
Stephan<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>