<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVEtvnDAQ_jXmMioCs8vjwCHJdnNNpd4jAwO4MjbyI-n--w4szXbTjaKqyDw8883rmzGN6U41y5NtJQeW3DGeSd2q0CGw7KEVzqH1LPt6S2uF7sx0Ua5PqT1MQmrGS8YrYMX9WQ50-dOMHfbgfMeyO1rKDNrYSajnTjpvZRO8NJpck1M4sOyG7eFsOQsrpudFCE83cW8xJp9WVVbA4xXsEYar_QG6t_1F2hrtPDzBnFK9BInXsOfSrszfgPwT4EYoL88uF_DM34M6ExqFYLeohB4Yf6AszkBg_EgLvo_SgZIaYQoUXRti3nSyPxEy_oeQrDhsH9ezoGTTMn5PC3ohlQM_IvRSCwWE2dwSmFJrsBXB4SL_q0EkA4etRa9OC1GepsOBgNfRqNXi1giQjWl-YOtXDpfCgaZtyUAvJu84-SACydfGPNMc-xVkQHpohaZbKfIm_McJMF64RWtmtMIbu3UzT-Koq7OuyioRieBHY-tvIfycVXBGYxSsqkfvZ7fwsDZqkH4MTdzSWeFHpV5-v77M1pxLPErnAjr62PMqyaOxbopdnzd70ZTlbl8WO6zSsq9EzvM9zztMIyUaVK5me-oPv3SKNmx_iP4_BVnzhKcp5yXnuzLL4iRPeZb0mJQpF6LYsV2CdNBVvPiJjR0iW68umzA4Uipi012UNC5y0Ihbxn8wtqXspVdYf_JrWHtnXtC-WulxO3YTTsaeorWAes3-F4OrcXw>52906</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::lognormal_distribution can overwrite const memory
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
Quuxplusone
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Quuxplusone
</td>
</tr>
</table>
<pre>
```
#include <cassert>
#include <random>
int main() {
typedef std::lognormal_distribution<> D;
typedef D::param_type P;
typedef std::mt19937 G;
G g;
D d;
const P p1 = d.param();
const P p2 = d.param();
assert(p1 == p2);
double r1 = d(g, p1); // This line must not modify p1.
assert(p1 == p2);
}
```
libc++ fails the final `assert`, because `D::param_type` secretly contains a whole `normal_distribution` object(!) and then `d(g, p1)` secretly contains a `const_cast` so it can call that `normal_distribution`'s `operator()`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVU0tvnDAQ_jXmMioCm92FA4ckdHNNpd5XBgy4MjbyI-n--w6P7nbTjaIgA_bMN_PNy7VpzyXZJ9tKKpI8EMqkblRoBRD21HDnhPWEfb-ntVy3Zrwql6_UHkYuNaE5oQWQw-MqB3z8eRKt6MD5lrAHXMr02tiRq1MrnbeyDl4aja7RKVSE3bGtVsuJWz6eZiG83MVdOEafFgU7wPMN7Bn6m3MF7eV8lTZGOw8vMKWYL0LihXZN7cb8AqSfALeC0nx1OYMn-h7UmlArAXZjRXRP6BNGsQKB0CMu-DlIB0pqAWNAdm2w8qaV3RmR8RcoyaHaNrezoGTdEPqICzoulQM_COik5goQs7lFMIZWi4YHJ2b5fw1CGTjRWOHVeS6Ux-lwwOFtMGqxuDcCaGPqX6LxSw3nxAGnbY5AzybvavIBA8qXxpxwjv0CMiA9NFzjqxR64_7jAAg9uFlrJmG5N3br5j6Jo7ZkbcEKHnnplSg_meeF0LwK-2alF9usjGI09hwFq8rB-8nNDpa29tIPoY4bvFn0qNTr39-3yZq1IEfpXBAONztaJPtoKIuO1d0-S3Y5K7qCZznlNCtY3hR81xZNHileC-VKssNu0mtf8UB2VSRLmtA0pTSnNMsZi5N9SlnSiSRPKeeHjGSJwEut4jmQ2Ng-suUSUx16h0qF2bqrEkdD9lqIje9HCL8nFZzRYiPkwQ_Glv8ooiWncknoD1HZXAw">