very strange segmentation fault interfacing a GSL-function
Stephan
ss27 at sanger.ac.uk
Tue May 15 08:44:46 PDT 2012
Hi,
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.
gsltest.d
--------------------------
import std.stdio;
extern (C) double gsl_sf_hyperg_2F1(double a, double b, double c,
double x);
void main() {
double f = 0.0025;
// The following line causes a crash
auto ret = f * gsl_sf_hyperg_2F1(1.0, 10.0, 11.0, 1.0 - f /
0.025);
// The following line should be identical, but it does not
cause the seg fault.
// auto ret = 0.0025 * gsl_sf_hyperg_2F1(1.0, 10.0, 11.0, 1.0 -
f / 0.025);
writeln(ret);
}
---------------------------
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.
To compile and run the code, I used the following command line:
rdmd -L-L/opt/local/lib -L-lgsl -L-lgslcblas gsltest.d
I tested this on Unix and Mac OS X. Can anyone reproduce the
error and have an idea what is going on?
Cheers,
Stephan
More information about the Digitalmars-d
mailing list