[Bug libstdc++/48114] [C++0x] binomial_distribution incorrect for p > .5 and geometric_distribution wrongly implements the TR1 definition
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 --- Comment #20 from Andrey Zholos 2011-03-16 22:43:45 UTC --- Good idea. The testcases should be adapted to the code paths in the GCC generators though: for instance, binomial with p > .5 isn't covered there. And BINS should be increased: for instance in the binomial(.3, 5500) testcase the most frequent outcomes are around 1650, but BINS only covers outcomes up to 100.
[Bug libstdc++/48114] [C++0x] binomial_distribution incorrect for p > .5 and geometric_distribution wrongly implements the TR1 definition
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 --- Comment #12 from Andrey Zholos 2011-03-14 18:07:22 UTC --- The double __p also fixes an infinite (maybe) loop in both binomial_distribution(100, .75) and binomial_distribution(100, .25) when _GLIBCXX_USE_C99_MATH_TR1 is defined. I guess the proper way to test the algorithms is to generate a lot of values and do a Pearson's chi-square test to check that the distribution is correct. Then that can be used to make a faster testcase for just a few values.
[Bug libstdc++/48114] [C++0x] binomial_distribution incorrect for p > .5 and geometric_distribution wrongly implements the TR1 definition
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 --- Comment #8 from Andrey Zholos 2011-03-14 17:34:01 UTC --- Ah, yes, I only looked at the C++0x formulas. By the way, testcases for these don't need to sample probabilities. They can just check, say, the first 100 values drawn using a deterministic generator.
[Bug libstdc++/48114] binomial_distribution incorrect for p > .5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 --- Comment #4 from Andrey Zholos 2011-03-14 15:25:14 UTC --- Created attachment 23652 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23652 Probability table for geometric_distribution.
[Bug libstdc++/48114] binomial_distribution incorrect for p > .5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 --- Comment #3 from Andrey Zholos 2011-03-14 15:23:25 UTC --- I'll add this here since it's in the same place and the test will be similar. For geometric_distribution(.25) the first 10 probabilities are: sample correct p_0 0.000 0.250 p_1 0.750 0.188 p_2 0.187 0.141 p_3 0.046 0.105 p_4 0.012 0.079 p_5 0.003 0.059 p_6 0.001 0.044 p_7 0.000 0.033 p_8 0.000 0.025 p_9 0.000 0.019 The smallest value returned is 1, but should be 0 (and d.min() is correctly 0); and p is used as 1-p. Fix: --- include/c++/bits/random.h +++ include/c++/bits/random.h @@ -3628,8 +3628,8 @@ void _M_initialize() - { _M_log_p = std::log(_M_p); } + { _M_log_1_p = std::log(1 - _M_p); } double _M_p; - double _M_log_p; + double _M_log_1_p; }; --- include/c++/bits/random.tcc +++ include/c++/bits/random.tcc @@ -1027,3 +1027,3 @@ do - __cand = std::ceil(std::log(__aurng()) / __param._M_log_p); + __cand = std::floor(std::log(__aurng()) / __param._M_log_1_p); while (__cand >= __thr); Also, there's a line in random.h _GLIBCXX_DEBUG_ASSERT((_M_p >= 0.0) && (_M_p <= 1.0)); but the standard only requires 0 < p < 1.
[Bug libstdc++/48114] New: binomial_distribution incorrect for p > .5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48114 Summary: binomial_distribution incorrect for p > .5 Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: a...@althenia.net Created attachment 23651 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23651 Probability table for binomial_distribution. The attached program samples binomial_distribution(10, .75) and calculates the correct probabilities of each outcome. The output shows that the probabilities are reversed. With p > .5 the distribution should be biased toward higher values. sample correct p_0 0.056 0.000 p_1 0.185 0.000 p_2 0.283 0.000 p_3 0.252 0.003 p_4 0.147 0.016 p_5 0.058 0.058 p_6 0.016 0.146 p_7 0.003 0.250 p_8 0.000 0.282 p_9 0.000 0.188 p_100.000 0.056 The problem is here, __param.p() is a double. --- include/c++/bits/random.tcc +++ include/c++/bits/random.tcc @@ -1434,7 +1434,7 @@ { result_type __ret; const _IntType __t = __param.t(); - const _IntType __p = __param.p(); + const double __p = __param.p(); const double __p12 = __p <= 0.5 ? __p : 1.0 - __p; __detail::_Adaptor<_UniformRandomNumberGenerator, double> __aurng(__urng);
[Bug c++/43281] [c++0x] ICE with invalid auto
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43281 Andrey Zholos changed: What|Removed |Added CC||aaz at althenia dot net --- Comment #5 from Andrey Zholos 2010-10-17 12:10:12 UTC --- This valid code triggers the new error message: template struct A { int f(); void g() { auto x = f(), y = x; } };
[Bug c++/42336] [c++0x] ICE with pointer-to-member-function decltype argument in template function
--- Comment #2 from aaz at althenia dot net 2009-12-10 00:07 --- To be more specific, it happens only with -O -fipa-sra -finline-small-functions -g -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42336
[Bug c++/42336] New: [c++0x] ICE with pointer-to-member-function decltype argument in template function
The following reduced program produces an ICE when compiled with -std=c++0x -O2 -g. = struct X { void func() {} }; template void b(T) {} int main() { b(X()); /* line 9 */ X().func(); return 0; } = 1.cc: In function 'void b(T) [with T = X, U = void (X::*)()]': 1.cc:9:9: internal compiler error: in build_ptrmem_type, at cp/decl.c:7202 And the following variation produces a different ICE. === struct X { void func() {} }; template struct A {}; template void b(T) {} int main() { b(A()); X().func(); return 0; } === Internal compiler error: Error reporting routines re-entered. -- Summary: [c++0x] ICE with pointer-to-member-function decltype argument in template function Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aaz at althenia dot net GCC build triplet: x86_64-portbld-freebsd8.0 GCC host triplet: x86_64-portbld-freebsd8.0 GCC target triplet: x86_64-portbld-freebsd8.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42336
[Bug c++/40619] [c++0x] ICE on repeated decltype expression in auto functions
--- Comment #4 from aaz at althenia dot net 2009-07-04 12:54 --- It works. Thanks! -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40619
[Bug c++/40619] New: [c++0x] ICE on repeated decltype expression in auto functions
template struct X {}; template auto f(T t) -> X {} template auto g(T t) -> X {} Compiling with -std=c++0x gives decltype_ice.cc:4:52: internal compiler error: Segmentation fault: 11 -- Summary: [c++0x] ICE on repeated decltype expression in auto functions Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: aaz at althenia dot net GCC build triplet: x86_64-portbld-freebsd7.2 GCC host triplet: x86_64-portbld-freebsd7.2 GCC target triplet: x86_64-portbld-freebsd7.2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40619