<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54668>54668</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] bugprone-exception-escape reported for structs with std::string
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
michaelvlach
</td>
</tr>
</table>
<pre>
Starting with LLVM-14 the very useful `bugprone-exception-escape` check became borderline useless:
```
struct S
{
std::string name;
};
```
will yield:
```
error: an exception may be thrown in function 'S' which should not throw exceptions [bugprone-exception-escape]
```
Needless to say it's almost every class/struct so having `NOLINT` on all of them is not an options. Defining all special members for structs like these is not reasonable either so one has to simply disable the check completely which is a shame.
And it is wrong anyway. In the above it CANNOT throw an exception at all. The move constructor of `std::string` is `noexcept` as is the destructor. Even if they did throw for whatever reason it would call `std::abort` so it is of no concern of `S` either way. The situation is slightly more complicated with the move assignment `operator=(&&)` but that is not what is being complained about here. The `function S` must be referring to the move constructor unless the warning message is wrong as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1VMFu2zAM_RrnQiRw7DRNDjm0ywoM6LJDi91lm4m1yVIgyfHy93uUnbUb1sJtFJMi33t8bOWa6-4lKh-1PdGgY0vPz9-_zpcrii3Thf2V-sDH3lC2zqv-dPbO8px_1XyO2tk5h1qdGTGqW65_UsW16pgq5xv2RluW64ZDyMqHLN9n-QNypyd9DdH3daSXKXj_OB4IPyE2cquUHIFnUTkrH2-Z-7fz3yUHbQxdNZvmo6bsvfMIkrL0hwt16gr8IO7dYElbOva2TpGsuH_BLw2trlsKretNQ9bFMfetRKDs7vFjle72_0VzYG5EIoqOAjDoiF6BlOlciMRpCLVR0LB4muQKjlp1EVFQ5fDt-cvhVWYAqArc3VGm15EOCSRIuhHegvZ81FbuSV44c62VoY67in2go_M0Nghk9E-RggPfynhWwVlVGSaGUdgLCvAEkhG67s7mSo0OKUf8M3qidghwZARHAVFQQUWMczEJkv4-2AbcJTpAP0C010FdF_TFpmKqcheWhE8Ph8O310n7vyaoovBa0CvSO8muQToRAjOoAo3-MZWohob4sG6sI29ACC-lacO3-wv6fGHYImkrNJsJgag2tCrKoCaRBOWQTFKLzu_bgoVPPSDeSBa4rBOkNXs7oXyRjEnlpIEwCjr2KvHErWD0qY2QtHOeR4l1DRDNuMXxpgBso0-2YxulrjuzV1G8v8-KTVas07OVblUvdlbxNu5hOlcsdkkNFPa5kTkgFch4hIXLfxYl4e562BaL5PmIRZPbcEf830h6O_oesUH55MsOL9SJ37kAB8ZQZ82ubLblVs2ijoZ32DQshT3No26uWC36cO8A5AzRAf29wZNM_7hh1nuza2M8p39XxROeE9L6agH--GLM5fYxR68fXGNVn3QIPcty3q3W682s3eV8XB6Lbb1qquWx2QD1el1u8mrF61Ll9-uZURWbIBSyorA8UCqBM3jM9K7IiyIvy2W-XW6K9WJV3d-tmAuUVFxu62yVc6e0WQiOhfOnmd8lSFAgIGh0iOEtODqAk2JSX_WxdX7XYRMVm4tRdTtL_XcJ_2-sCgkV">