Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P1339 Disallowing the friending of names in namespace std #161

Open
jensmaurer opened this issue Jan 26, 2019 · 8 comments
Open

P1339 Disallowing the friending of names in namespace std #161

jensmaurer opened this issue Jan 26, 2019 · 8 comments
Labels
B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed policy ready-for-library-evolution-meeting-review This paper needs to be discussed at a Library Evolution meeting size - small paper size estimate

Comments

@jensmaurer
Copy link
Member

P1339R0 Disallowing the friending of names in namespace std (CJ Johnson)

@jensmaurer jensmaurer added this to the 2019-02 milestone Jan 26, 2019
@jensmaurer jensmaurer added the LEWG Library Evolution label Jan 26, 2019
@jensmaurer jensmaurer added this to Thursday in LEWG in Kona 2019 Feb 6, 2019
@tituswinters
Copy link

tituswinters commented Feb 21, 2019

LEWG in Kona:
Assume that users have not given types in namespace std access to non-public members of their types unless otherwise permitted by the standard.

(Change “private” to “non-public”). Forward to LWG to update SD-8.
SF F N A SA
8 8 1 0 0

@tituswinters tituswinters added LWG Library and removed LEWG Library Evolution labels Feb 21, 2019
@jensmaurer jensmaurer removed this from Thursday in LEWG in Kona 2019 Feb 24, 2019
@wg21bot
Copy link
Collaborator

wg21bot commented Mar 20, 2019

P1339R1 Disallowing the friending of names in namespace std (CJ Johnson)

@wg21bot wg21bot modified the milestones: 2019-02, 2019-07 Mar 20, 2019
@mclow
Copy link

mclow commented Jul 9, 2019

This can be updated post-Cologne; since it doesn't affect the standard directly.

@mclow mclow modified the milestones: 2019-07, 2019-11 Jul 9, 2019
@jensmaurer jensmaurer modified the milestones: 2019-11, 2020-06 Feb 18, 2020
@ben-craig ben-craig added B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e size - small paper size estimate labels Oct 17, 2020
@jensmaurer jensmaurer modified the milestones: 2020-telecon, 2021-telecon Dec 28, 2020
@JeffGarland
Copy link
Member

Per chair discussion since this is LEWG policy paper LWG will not review further.

@JeffGarland JeffGarland added LEWG Library Evolution and removed LWG Library labels Jan 27, 2021
@brycelelbach brycelelbach added the ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list label Feb 23, 2021
@inbal2l inbal2l added the scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review label Jun 1, 2021
@inbal2l
Copy link
Collaborator

inbal2l commented Jul 2, 2021

Was reviewed on LEWG mailing list.
Attaching a summary of the feedback for this proposal:

  1. Generally good reaction to the direction (the example of friending "make_shared"was brought up). There was a suggestion of an alternative phrasing:
    To make friending names in std:: useless by making it clear that any invocation described in a component's effects aren't necessarily done as that component, but may be done by some delegated component.

  2. A discussion about SD-8 (https://isocpp.org/std/standing-documents/sd-8-standard-library-compatibility) vs. the standard as the platform:

    For in standard:

    1. SD-8 gives hints how the standard may evolve in future revisions.
    2. Currently the standard "say" (by omission) that befriending std::things has no effect. The text to disallow it needs to be in the standard (Somewhere in [constraints] might be a good spot).
    3. When curious users run into such problems, their more-knowledgeable friends point them to the exact words, both as a quotation and as a chapter & verse reference to the standard. (...)
    4. Sounds like a Note to help make that clearer to non-experts (perhaps indirectly via the usual-suspect books and blogs) would be very helpful, then.
    5. Examples given for existing restrictions: https://eel.is/c++draft/namespace.std#6, https://eel.is/c++draft/algorithms.requirements#15

    For in SD-8:

    1. Given that the status quo is that befriending std:: things has no normative effect, I think SD-8 is fine.
    2. WG21 already effectively communicates to expert implementors that friending things in the STL has no normative effect. The point of CJ's feature request AIUI is to add "friending things in the STL" into the specific document that we maintain for the purpose of telling users "hey, authority says, don't do these things."
  3. Discussion regarding whether the result of such use should be UB

    Example by Nevin:

    class A { 
        size_t do_hash() const;
        friend class std::hash<A>;
        template<typename T>
        friend class std::hash;
    };
    
    namespace std {
        template <>
        struct hash<A> {
            size_t operator()(A const& a) const { return a.do_hash(); }
        };
    };
    1. Granting friendship to operations that aren’t part of a class but must have access to private/protected members are common – it’s not the users’ fault our “hashing protocol” is a class that has to be specialized.
    2. We want to say that befriending library entities is UB, but befriending program-defined specializations (or program-defined non-template customization points) is fine, since program-defined entities are the responsibility of the program, as long as they don't otherwise violate their requirements.

To conclude: This topic, as it reveals a major discussion of "indicating the correct usage to users", should be scheduled to an LEWG Telecon.

@inbal2l inbal2l added ready-for-library-evolution-meeting-review This paper needs to be discussed at a Library Evolution meeting and removed ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list scheduled-for-library-evolution This paper has been scheduled for one of the groups: LEWG, LEWG Incubator, or a Mailing List review labels Jul 2, 2021
@brycelelbach brycelelbach added library-evolution-deferred Ready for review, but should not be scheduled IS Ship vehicle: IS labels Aug 1, 2021
@brycelelbach brycelelbach added C++23 Targeted at C++23 and removed library-evolution-deferred Ready for review, but should not be scheduled labels Aug 1, 2021
@brycelelbach
Copy link

Deferred to C++26 due to lack of time.

@brycelelbach brycelelbach added C++26 Targeted at C++26 and removed C++23 Targeted at C++23 labels Nov 3, 2021
@jensmaurer jensmaurer modified the milestones: 2021-telecon, 2022-telecon Jan 1, 2022
@brycelelbach brycelelbach added ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list and removed ready-for-library-evolution-meeting-review This paper needs to be discussed at a Library Evolution meeting labels Feb 1, 2022
@brycelelbach
Copy link

Deferring as we lack a champion for this.

@brycelelbach brycelelbach added ready-for-library-evolution-meeting-review This paper needs to be discussed at a Library Evolution meeting library-evolution-deferred Ready for review, but should not be scheduled and removed ready-for-library-evolution-mailing-list-review This paper needs to be discussed on the Library Evolution mailing list labels Jun 19, 2022
@brycelelbach brycelelbach removed the library-evolution-deferred Ready for review, but should not be scheduled label Sep 23, 2022
@brycelelbach
Copy link

brycelelbach commented Sep 23, 2022

Marking as needs-revision as this is out of date.

@brycelelbach brycelelbach reopened this Sep 23, 2022
@brycelelbach brycelelbach added needs-revision Paper needs changes before it can proceed and removed C++26 Targeted at C++26 labels Sep 23, 2022
@jensmaurer jensmaurer removed this from the 2022-telecon milestone Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B2 - improvement Bucket 2 as described by P0592: bug fixes, performance improvements, integration fixes for/between e IS Ship vehicle: IS LEWG Library Evolution needs-revision Paper needs changes before it can proceed policy ready-for-library-evolution-meeting-review This paper needs to be discussed at a Library Evolution meeting size - small paper size estimate
Projects
None yet
Development

No branches or pull requests

9 participants