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

Attributes on hidden friends #6054

Closed
dangelog opened this issue Jan 18, 2023 · 4 comments
Closed

Attributes on hidden friends #6054

dangelog opened this issue Jan 18, 2023 · 4 comments

Comments

@dangelog
Copy link
Contributor

dangelog commented Jan 18, 2023

From this thread on the std-proposals ML: https://lists.isocpp.org/std-proposals/2023/01/5452.php


https://eel.is/c++draft/stoptoken.general declares the friend function

    [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;

This declaration is to be taken as a hidden friend as per https://eel.is/c++draft/hidden.friends . As such, an implementation will have no choice but to immediately define that function rather than just declare it.

However it's "mildly interesting" that the declaration above in the class synposis is actually ill-formed, per https://eel.is/c++draft/dcl.attr#grammar-5.sentence-3 :

If an attribute-specifier-seq appertains to a friend declaration ([class.friend]), that declaration shall be a definition.

AFAICS, [stoptoken.general] is the only place in the Standard Library where an attribute is used on a friend declaration.

I'm not sure if it should be fixed editorially somehow, for instance by adding another note to [hidden.friends] that says that such declarations may have attributes which are meant to be interpreted as attributes appearing on the definition, or something along those lines. Are there any other places where the Standard Library shows actual code (no "exposition only" / "see below" / etc.) that actually is ill-formed?

@jensmaurer
Copy link
Member

We show (otherwise ill-formed) repeated default arguments in the various synopses, for example.

@dangelog
Copy link
Contributor Author

Ok, so nothing to do, and one should "read between the lines" to interpret the synopsys code correctly?

@jwakely
Copy link
Member

jwakely commented Jan 18, 2023

Yes, it tells you the API, it's not meant to be a conforming implementation.

@jensmaurer
Copy link
Member

In particular, [intro.compliance.general] p4 says

For functions, function templates, objects, and values, the library Clauses specify declarations. Implementations shall supply definitions consistent with the descriptions in the library Clauses.

So, this explicitly says the implementation must plug in a definition. Nothing to see here, I guess.

@jensmaurer jensmaurer closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants