very strange segmentation fault interfacing a GSL-function

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Tue May 15 09:02:51 PDT 2012


Does it crash if you just call the function with no extra multiplication?

On Tue, May 15, 2012 at 7:44 PM, Stephan <ss27 at sanger.ac.uk> wrote:

> 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
>
>


-- 
Bye,
Gor Gyolchanyan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120515/158c8d1b/attachment.html>


More information about the Digitalmars-d mailing list