From: Jonathan Wakely <jwakely@redhat.com>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: libstdc++@gcc.gnu.org
Subject: Re: [committed] libstdc++: Find make_error_code and make_error_condition via ADL only
Date: Tue, 16 May 2023 12:23:22 +0100 [thread overview]
Message-ID: <CACb0b4nkJZMoty5WGDbFE7e17oqMzbARj4npdK1+TyDPmOZGPA@mail.gmail.com> (raw)
In-Reply-To: <20220908183010.3290473-1-jwakely@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3819 bytes --]
For the record (i.e. so I don't have to remember/rediscover this), I tried
to backport this change to gcc-11 but it doesn't work on that branch
because of PR 68942 ("overly strict use of deleted function before
argument-dependent lookup (ADL)").
We can live with it being a gcc-12+ feature.
On Thu, 8 Sept 2022 at 19:30, Jonathan Wakely wrote:
> Tested powerpc64le-linux, pushed to trunk.
>
> -- >8 --
>
> The new proposed resolution for LWG 3629 says that std::error_code and
> std::error_condition should only use ADL to find their customization
> points. This means we need to use a poison pill to prevent lookup from
> finding overloads in the enclosing namespaces.
>
> We can also remove the forward declarations of std::make_error_code and
> std::make_error_condition, because they aren't needed now. ADL can find
> them anyway (when std is an associated namespace), and unqualified name
> lookup will not (and should not) find them.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/system_error (__adl_only::make_error_code): Add
> deleted function.
> (__adl_only::make_error_condition): Likewise.
> (error_code::error_code(ErrorCodeEnum)): Add using-declaration
> for deleted function.
> (error_condition::error_condition(ErrorConditionEnum)):
> Likewise.
> * testsuite/19_diagnostics/error_code/cons/lwg3629.cc: New test.
> * testsuite/19_diagnostics/error_condition/cons/lwg3629.cc: New
> test.
> ---
> libstdc++-v3/include/std/system_error | 18 +++++--
> .../19_diagnostics/error_code/cons/lwg3629.cc | 48 +++++++++++++++++++
> .../error_condition/cons/lwg3629.cc | 48 +++++++++++++++++++
> 3 files changed, 109 insertions(+), 5 deletions(-)
> create mode 100644
> libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc
> create mode 100644
> libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
>
> diff --git a/libstdc++-v3/include/std/system_error
> b/libstdc++-v3/include/std/system_error
> index 050439427cc..e12bb2f0e1e 100644
> --- a/libstdc++-v3/include/std/system_error
> +++ b/libstdc++-v3/include/std/system_error
> @@ -195,7 +195,11 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
> * @{
> */
>
> - error_code make_error_code(errc) noexcept;
> +namespace __adl_only
> +{
> + void make_error_code() = delete;
> + void make_error_condition() = delete;
> +}
>
> /** Class error_code
> *
> @@ -231,7 +235,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
> template<typename _ErrorCodeEnum,
> typename = _Check<_ErrorCodeEnum>>
> error_code(_ErrorCodeEnum __e) noexcept
> - { *this = make_error_code(__e); }
> + {
> + using __adl_only::make_error_code;
> + *this = make_error_code(__e);
> + }
>
> error_code(const error_code&) = default;
> error_code& operator=(const error_code&) = default;
> @@ -330,8 +337,6 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
> operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code&
> __e)
> { return (__os << __e.category().name() << ':' << __e.value()); }
>
> - error_condition make_error_condition(errc) noexcept;
> -
> /** Class error_condition
> *
> * This class represents error conditions that may be visible at an API
> @@ -363,7 +368,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
> template<typename _ErrorConditionEnum,
> typename = _Check<_ErrorConditionEnum>>
> error_condition(_ErrorConditionEnum __e) noexcept
> - { *this = make_error_condition(__e); }
> + {
> + using __adl_only::make_error_condition;
> + *this = make_error_condition(__e);
> + }
>
> error_condition(const error_condition&) = default;
> error_condition& operator=(const error_condition&) = default;
>
>
prev parent reply other threads:[~2023-05-16 11:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 18:30 Jonathan Wakely
2022-09-12 10:55 ` Daniel Krügler
2022-09-12 11:04 ` Jonathan Wakely
2023-05-16 11:23 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACb0b4nkJZMoty5WGDbFE7e17oqMzbARj4npdK1+TyDPmOZGPA@mail.gmail.com \
--to=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).