Back in 2010, the algorithm for this function was updated, adding the following clause:

if (__x < 10)

{

const result_type __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040,

40320, 362880};

__px = -__pr._*mean*;

__py = _VSTD::pow(__pr._*mean*, (double)__x) / __fac[__x];

}

In this case, result_type is the single template parameter to the instantiation of std::poisson_distribution.

In the case that std::poisson_distribution is instantiated with a 16-bit signed integral type, __fac[8] and __fac[9] are out of range of result_type, and are truncated or result in a change of sign.

Since the only use of __fac is as an operand to a double-precision floating point division, would it not make sense to instead declare it ‘double’ instead of ‘result_type’, and then modify the values populating it to be doubles?

Regards,

J.B. Nagurne

Code Generation

Texas Instruments