<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56996>56996</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`modernize-use-emplace` not reported for `std::stack`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <stack>
#include <string>
struct A {
std::string s;
};
void f1() {
std::stack<A> s;
s.push(A()); // no warning
}
void f2() {
std::stack<A> s;
s.push(A{}); // no warning
}
void f3() {
std::stack<A> s;
s.push(A{""}); // no warning
}
void f4() {
std::stack<A> s;
s.push({}); // no warning
}
void f5() {
std::stack<A> s;
s.push({""}); // no warning
}
void f6() {
std::stack<A> s;
s.emplace(A()); // warning
}
```
https://godbolt.org/z/sq6K8MchT
Interestingly the warning about the usage of unnecessary temporary objects is being reported so it seems like `std::stack` is not excluded from this check in general:
```
<source>:35:15: warning: unnecessary temporary object created while calling emplace [modernize-use-emplace]]
s.emplace(A()); // warning
^~~
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVNtu2zAM_Rr5hUjgSLETPfghbTJgGPa2H5BlxtaqWJkkN2u_fpTT9LZkwNLatEyJIs8hdald81CxMj-K3u9Zvmb5inFhem2HBoGJ2xCVvmNic97mTd--GMeWBgcdYQVscXMcAXpCbJhYkRx9IDDxZGWL9Ys-tvfONLCdMb5kXF4MM9K6JX3zKtg4Z7ofQkfeq2OEJOIGGP9CAr2Dg_J94v0M_xc2_wRscqXQ_48tPgeb8yRXMZh_mMHVyRefAv2B3MvrCeBub5XGSxvvAvbp-B27XYz7kLBGn9Y1tbNx6nxLvUf6wq_y2_K77n68Zv61j-gxRIpuHyB2eMICVbshjiNDUC2C28LQ96gxBOVpKlF2Pmmu_ok6BjABakyeHskSsYHgwEQIiLsA1tzRuS_zd_Uo8-TXuwj4e7wbqI7e7QiXhnWH-g5MDy326JVNjucyT9eJGzzVj64TsRIFNbPUPBeO1H-RB-1RJcaHzlgEraxNiTytCrDiZucapFCPOBkCTk7LVayTXLmO8OZhxYYtRnmbYYbVrCyknM-XUmZNJRoppMqiiRbTBXyeGJU11fR5JbbOny1-Nnhbvds4JnZDPdVuRx1r70-_yd67VCvqmhAGDKQUpZRl1lW8EEJjKWa8QGxKJbWUmjdEeSaUKJrMqhptqKiQdLp6PMAYIp20Yp2Ziuec50t6F_PlbDlVqpEqX6CQhShVztk8x50ydpp4pB2d-WqkVA9tIKM1IYYXowrBtD3iCEfx1RA756ut8XhQ95iN2NXI_Q__oeWG">