[LLVMbugs] [Bug 21344] New: False positive garbage value reported in std::<random> param_type in distribution templates
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Oct 22 14:10:35 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=21344
Bug ID: 21344
Summary: False positive garbage value reported in std::<random>
param_type in distribution templates
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: kremenek at apple.com
Reporter: stevemac321 at live.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
To repro, navigate to
/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin
Run:
scan-build -k -analyze-headers clang++ -std=c++1y -stdlib=libc++ -g3 -O0
-I/home/comet/libcxx/include eval_param.pass.cpp
Result:
libcxx/include/random:4024:29: warning: The right operand of '-' is a garbage
value
double __u = __gen(__g) - __pr.__pr_;
^ ~~~~~~~~~~
The code looks like this:
template<class _IntType>
template<class _URNG>
_IntType
binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr)
{
if (__pr.__t_ == 0 || __pr.__p_ == 0)
return 0;
if (__pr.__p_ == 1)
return __pr.__t_;
uniform_real_distribution<double> __gen;
double __u = __gen(__g) - __pr.__pr_; // warning on this line
However, I think it is fair to say that param_type will at least be a
default-constructed IntType. IntType is binomial_distribution's template
argument defaulted to int (class _IntType = int). param_type has to be
assignable to numeric types:
explicit param_type(result_type __t = 1, double __p = 0.5);
So, I don't know how a garbage value could compile, or how one would test for
garbage in binomial_distribution's call operator (warning location)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141022/a17c064c/attachment.html>
More information about the llvm-bugs
mailing list