This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86556] New: <random>, most vexing parse, and diagnostic output
- From: "nightstrike at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 17 Jul 2018 23:28:01 +0000
- Subject: [Bug c++/86556] New: <random>, most vexing parse, and diagnostic output
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86556
Bug ID: 86556
Summary: <random>, most vexing parse, and diagnostic output
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nightstrike at gmail dot com
Target Milestone: ---
This works:
#include <random>
bool f() {
std::random_device r;
std::mt19937 gen(r());
std::bernoulli_distribution d(0.5);
return d(gen);
}
This easy to make but clearly wrong typo produces incomprehensible (to me)
errors:
#include <random>
bool f() {
std::mt19937 gen(std::random_device());
std::bernoulli_distribution d(0.5);
return d(gen);
}
In file included from /gcc/gcc8/include/c++/8.1.0/random:51,
from rand.cc:1:
/gcc/gcc8/include/c++/8.1.0/bits/random.tcc: In instantiation of '_RealType
std::generate_canonical(_UniformRandomNumberGenerator&) [with _RealType =
double; long unsigned int __bits = 53; _UniformRandomNumberGenerator =
std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)())]':
/gcc/gcc8/include/c++/8.1.0/bits/random.h:181:38: required from '_DInputType
std::__detail::_Adaptor<_Engine, _DInputType>::operator()() [with _Engine =
std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)()); _DInputType = double]'
/gcc/gcc8/include/c++/8.1.0/bits/random.h:3562:14: required from
'std::bernoulli_distribution::result_type
std::bernoulli_distribution::operator()(_UniformRandomNumberGenerator&, const
std::bernoulli_distribution::param_type&) [with _UniformRandomNumberGenerator =
std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)()); std::bernoulli_distribution::result_type
= bool]'
/gcc/gcc8/include/c++/8.1.0/bits/random.h:3553:49: required from
'std::bernoulli_distribution::result_type
std::bernoulli_distribution::operator()(_UniformRandomNumberGenerator&) [with
_UniformRandomNumberGenerator = std::mersenne_twister_engine<long unsigned int,
32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752,
18, 1812433253>(std::random_device (*)());
std::bernoulli_distribution::result_type = bool]'
rand.cc:5:14: required from here
/gcc/gcc8/include/c++/8.1.0/bits/random.tcc:3323:63: error: request for member
'max' in '__urng', which is of non-class type
'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)())'
const long double __r = static_cast<long double>(__urng.max())
~~~~~~~^~~
/gcc/gcc8/include/c++/8.1.0/bits/random.tcc:3324:42: error: request for member
'min' in '__urng', which is of non-class type
'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)())'
- static_cast<long double>(__urng.min()) + 1.0L;
~~~~~~~^~~
/gcc/gcc8/include/c++/8.1.0/bits/random.tcc:3333:29: error: too few arguments
to function
__sum += _RealType(__urng() - __urng.min()) * __tmp;
~~~~~~^~
/gcc/gcc8/include/c++/8.1.0/bits/random.tcc:3333:41: error: request for member
'min' in '__urng', which is of non-class type
'std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615,
11, 4294967295, 7, 2636928640, 15, 4022730752, 18,
1812433253>(std::random_device (*)())'
__sum += _RealType(__urng() - __urng.min()) * __tmp;
~~~~~~~^~~