<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58575>58575</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
_LIBCPP_DISABLE_NODISCARD_EXT should not affect _LIBCPP_NODISCARD_AFTER_CXX17
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
higher-performance
</td>
</tr>
</table>
<pre>
This is a hybrid bug report/feature request.
The `_LIBCPP_NODISCARD_AFTER_CXX17` flag in libc++ is defined as follows:
https://github.com/llvm/llvm-project/blob/3c355e2881887fea6f4b31e26b68aefa4d216fd0/libcxx/include/__config#L867-L871
Unfortunately this has 2 issues:
- `_LIBCPP_DISABLE_NODISCARD_EXT` now controls both standard _and_ non-standard extensions to the `[[nodiscard]]` annotations, which is contrary to what its name would suggest.
- It is impossible to turn on standard C++20 `[[nodiscard]]` without also enabling non-standard extensions, which can make valid C++ code fail to compile, and thus makes migrations to C++20 unnecessarily difficult.
Could the conditions be changed to alleviate this? I think they could be changed to something like
```
# if _LIBCPP_STD_VER > 17 || !defined(_LIBCPP_DISABLE_NODISCARD)
```
if backward compatibility is not needed, or something like
```
# if _LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD_AFTER_CXX17) || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
```
if backward compatibility is needed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVdtu4zYQ_Rr5ZWBDoq5-0EPiCxAg2C6y7iJvBimOJDY06YpUHP99h3ISZ9tugC1qDERR5MycOXOxsPJc73rlgIRDfxaDkiDGDgY82sFHbNsi9-OA9OHPEZ1fRPE6im8uz12PEBXx_v7udvX16_7Lb-u7b6ubh_X-ZrvbPOxXj49JSefQat6BMqCVaCJ2SxL8SWyVQQncQWu1ticXpa-Ge--P045tSTrl-1EsGnugjdbPb8v8ONg_sA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