[libcxx-dev] Proposal to replace `_LIBCPP_NODISCARD_EXT` with `[[nodiscard]]`

Zoe Carver via libcxx-dev libcxx-dev at lists.llvm.org
Thu May 13 11:02:33 PDT 2021


Hello, Chris, all.

I agree that it would be a good idea to move away from
"_LIBCPP_NODISCARD_EXT". All of our supported compilers have a flag to
disable "[[nodiscard]]", which is probably a better thing for people to use
than this inconsistent configuration macro. I also doubt that we have any
configuration that tests with this.

Thanks.

On Thu, May 13, 2021 at 10:47 AM Christopher Di Bella via libcxx-dev <
libcxx-dev at lists.llvm.org> wrote:

> Hi folks,
>
> There's been a lot of requests for `[[nodiscard]]` to be replaced with `
> _LIBCPP_NODISCARD_EXT` in recent reviews where the standard doesn't
> explicitly declare an entity with the nodiscard attribute. After some
> investigation, I've discovered that this feature is confusing and
> error-prone. `_LIBCPP_NODISCARD_EXT` is opt-in, which requires users to
> know about its existence (I certainly didn't until reviewers started asking
> for it, and even then, didn't expect it to be opt-in), and then has three
> ways to opt out of its use: `_LIBCPP_DISABLE_NODISCARD_EXT` (global), `
> -Wno-unused-result` (global), and cast to `void` (local).
>
> Since It's unclear why we want so many toggle options for this feature, this
> attribute doesn't change a user's program
> <http://eel.is/c++draft/dcl.attr.nodiscard>, and users already have two compiler-based
> opt-out mechanisms <https://godbolt.org/z/hsWo1v5W9> for all supported
> compilers and C++ standards, I think it's reasonable to remove this
> attribute in favour of the easier-to-use attribute itself.
>
> Kind regards,
>
> Christopher Di Bella
> _______________________________________________
> libcxx-dev mailing list
> libcxx-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-dev/attachments/20210513/6e6b0130/attachment.html>


More information about the libcxx-dev mailing list