使用std :: uniform_int_distribution时出现分段错误

时间:2015-02-03 00:41:47

标签: c++ c++11 random gcc-warning

我在下面的程序中遇到Segmentation fault。编译工作正常。

#include <random>
#include <iostream>

int main()
{
    std::random_device rd;
    std::mt19937 gen(rd());
    std::uniform_int_distribution<> dis(0, 19);

    for (int n=0; n<10; ++n)
        std::cout << dis(gen) << ' ';
    std::cout << '\n';
}

以下是错误

Program terminated with signal 11, Segmentation fault.
#0  std::uniform_int_distribution<int>::operator()<std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul> > (
    this=0xb10f40, __urng=..., __param=...)
    at /usr/include/c++/4.7/bits/random.tcc:864
864           uniform_int_distribution<_IntType>::

操作系统:Debian,gcc版本4.7.2

如果需要更多信息,请告诉我。

0 个答案:

没有答案