Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ gsl_复合体导致内存溢出_C++_Windows_Complex Numbers_Gsl - Fatal编程技术网

C++ gsl_复合体导致内存溢出

C++ gsl_复合体导致内存溢出,c++,windows,complex-numbers,gsl,C++,Windows,Complex Numbers,Gsl,我从GNU科学图书馆的复数函数中看到了一些奇怪的行为。以下代码片段演示了该问题: #include <iostream> #include <gsl/gsl_complex.h> #include <gsl/gsl_complex_math.h> int main() { double realNumber = 1.0; gsl_complex complexNumber; GSL_SET_COMPLEX(&complexN

我从GNU科学图书馆的复数函数中看到了一些奇怪的行为。以下代码片段演示了该问题:

#include <iostream>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>

int main() {
    double realNumber = 1.0;
    gsl_complex complexNumber;

    GSL_SET_COMPLEX(&complexNumber, 1.0, 1.0);

    printf("%p: ", &realNumber);
    printf("%f\n", realNumber);

    gsl_complex_add(complexNumber,complexNumber);

    printf("%p: ", &realNumber);
    printf("%f\n", realNumber);

    return 0;
}
函数
gsl\u complex\u add
更改指向
realNumber
的指针的值,使其不再指向
realNumber
,即使
realNumber
似乎没有以任何方式链接到函数。我想这是由于某种溢出

如果使用
std::cout
而不是
printf
,则不会出现问题;我想这应该归功于编译器

如果我将
realNumber
声明为
static
则不会出现问题

如果我将
realNumber
声明为
const
printf(“%p:”,&realNumber)返回不正确的值,但
printf(“%f\n”,realNumber)返回正确的代码

这是一只虫子还是我在做不该做的事

我正在Windows机器上使用g++编译器(版本6.3.0)


提前感谢您的帮助。

经过进一步调查,我意识到我使用的是非常旧的GSL版本。更新到最新稳定版本后,所描述的行为消失。

是调试、发布还是两种配置?我认为是默认的发布模式(除了相关库之外,没有编译器标志)。
0061FF18: 1.000000
0061FF1C: 0.000000