public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: "Daniel Krügler" <daniel.kruegler@gmail.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [committed] libstdc++: Find make_error_code and make_error_condition via ADL only
Date: Mon, 12 Sep 2022 12:04:44 +0100	[thread overview]
Message-ID: <CACb0b4=z0nM1ZQfwNSxAzZHSkawc-NKN=1zMN8zL0i2GHhjvXg@mail.gmail.com> (raw)
In-Reply-To: <CAGNvRgBjQY5F5F_gddfQAcSFOp_77zSqHGh2P3rhLmzw-xTUHw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5257 bytes --]

On Mon, 12 Sept 2022 at 11:55, Daniel Krügler <daniel.kruegler@gmail.com> wrote:
>
> Am Do., 8. Sept. 2022 um 20:30 Uhr schrieb Jonathan Wakely via
> Libstdc++ <libstdc++@gcc.gnu.org>:
> >
> > 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.
> > ---
> [..]
> > +// { dg-do compile { target c++11 } }
> > +
> > +// 3629. make_error_code and make_error_condition are customization points
> > +// Verify that make_error_code is looked up using ADL only.
> > +
> > +namespace user
> > +{
> > +  struct E1;
> > +}
> > +
> > +// N.B. not in associated namespace of E1, and declared before <system_error>.
> > +user::E1 make_error_code(user::E1);
> > +
> > +#include <future> // declares std::make_error_code(future_errc)
> > +#include <system_error>
> > +
> > +namespace user
> > +{
> > +  struct E1
> > +  {
> > +    operator std::error_code() const;
> > +  };
> > +
> > +  struct E2
> > +  {
> > +    operator std::future_errc() const;
> > +  };
> > +
> > +  struct E3
> > +  {
> > +    operator std::errc() const;
> > +  };
> > +}
> > +
> > +template<> struct std::is_error_code_enum<user::E1> : std::true_type { };
> > +template<> struct std::is_error_code_enum<user::E2> : std::true_type { };
> > +template<> struct std::is_error_code_enum<user::E3> : std::true_type { };
> > +
> > +// ::make_error_code(E1) should not be found by name lookup.
> > +std::error_code e1( user::E1{} ); // { dg-error "here" }
> > +
> > +// std::make_error_code(errc) should not be found by name lookup.
> > +std::error_code e2( user::E2{} ); // { dg-error "here" }
>
> (1) Unless I'm misunderstanding something here, the comment above
> doesn't match here, it should mention (std::)future_errc instead.
>
> > +// std::make_error_code(future_errc) should not be found by name lookup.
> > +std::error_code e3( user::E3{} ); // { dg-error "here" }
>
> (2) Unless I'm misunderstanding something here, the comment above
> doesn't match here, it should mention (std::)errc instead.
>
> > +// { dg-error "use of deleted function" "" { target *-*-* } 0 }
> > diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
> > new file mode 100644
> > index 00000000000..e34b53de8a1
> > --- /dev/null
> > +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
> > @@ -0,0 +1,48 @@
> > +// { dg-do compile { target c++11 } }
> > +
> > +// 3629. make_error_code and make_error_condition are customization points
> > +// Verify that make_error_condition is looked up using ADL only.
> > +
> > +namespace user
> > +{
> > +  struct E1;
> > +}
> > +
> > +// N.B. not in associated namespace of E1, and declared before <system_error>.
> > +user::E1 make_error_condition(user::E1);
> > +
> > +#include <future> // declares std::make_error_condition(future_errc)
> > +#include <system_error>
> > +
> > +namespace user
> > +{
> > +  struct E1
> > +  {
> > +    operator std::error_code() const;
> > +  };
> > +
> > +  struct E2
> > +  {
> > +    operator std::future_errc() const;
> > +  };
> > +
> > +  struct E3
> > +  {
> > +    operator std::errc() const;
> > +  };
> > +}
> > +
> > +template<> struct std::is_error_condition_enum<user::E1> : std::true_type { };
> > +template<> struct std::is_error_condition_enum<user::E2> : std::true_type { };
> > +template<> struct std::is_error_condition_enum<user::E3> : std::true_type { };
> > +
> > +// ::make_error_condition(E1) should not be found by name lookup.
> > +std::error_condition e1( user::E1{} ); // { dg-error "here" }
> > +
> > +// std::make_error_condition(errc) should not be found by name lookup.
> > +std::error_condition e2( user::E2{} ); // { dg-error "here" }
>
> Ditto here (1)
>
> > +// std::make_error_condition(future_errc) should not be found by name lookup.
> > +std::error_condition e3( user::E3{} ); // { dg-error "here" }
>
> Ditto here (2)


Good catch, thanks.

Fixed by the attached patch, tested x86_64-linux and pushed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2485 bytes --]

commit c092d894265f3db590585804c30c1ae3cb7b3773
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Sep 12 12:02:29 2022

    libstdc++: Fix comments in tests to match code
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/19_diagnostics/error_code/cons/lwg3629.cc: Fix
            comments.
            * testsuite/19_diagnostics/error_condition/cons/lwg3629.cc:
            Likewise.

diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc
index b1e0b7f0c81..70fa5e80503 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc
@@ -39,10 +39,10 @@ template<> struct std::is_error_code_enum<user::E3> : std::true_type { };
 // ::make_error_code(E1) should not be found by name lookup.
 std::error_code e1( user::E1{} ); // { dg-error "here" }
 
-// std::make_error_code(errc) should not be found by name lookup.
+// std::make_error_code(future_errc) should not be found by name lookup.
 std::error_code e2( user::E2{} ); // { dg-error "here" }
 
-// std::make_error_code(future_errc) should not be found by name lookup.
+// std::make_error_code(errc) should not be found by name lookup.
 std::error_code e3( user::E3{} ); // { dg-error "here" }
 
 // { dg-error "use of deleted function" "" { target *-*-* } 0 }
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
index e34b53de8a1..562a99aee3b 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc
@@ -39,10 +39,10 @@ template<> struct std::is_error_condition_enum<user::E3> : std::true_type { };
 // ::make_error_condition(E1) should not be found by name lookup.
 std::error_condition e1( user::E1{} ); // { dg-error "here" }
 
-// std::make_error_condition(errc) should not be found by name lookup.
+// std::make_error_condition(future_errc) should not be found by name lookup.
 std::error_condition e2( user::E2{} ); // { dg-error "here" }
 
-// std::make_error_condition(future_errc) should not be found by name lookup.
+// std::make_error_condition(errc) should not be found by name lookup.
 std::error_condition e3( user::E3{} ); // { dg-error "here" }
 
 // { dg-error "use of deleted function" "" { target *-*-* } 0 }

  reply	other threads:[~2022-09-12 11:04 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 [this message]
2023-05-16 11:23 ` Jonathan Wakely

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='CACb0b4=z0nM1ZQfwNSxAzZHSkawc-NKN=1zMN8zL0i2GHhjvXg@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=daniel.kruegler@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).