<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - False positive garbage value reported in std::<random> param_type in distribution templates"
   href="http://llvm.org/bugs/show_bug.cgi?id=21344">21344</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False positive garbage value reported in std::<random> param_type in distribution templates
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>kremenek@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stevemac321@live.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>