Skip to content

CWG2781 [basic.def.odr] "... for D itself, the behavior is as if there is a single entity with a single definition" renders the complere ODR teethless #402

Description

@RealLitb

The ODR applies to multiple definitions of the same entity. For example this is rendered IFNDR by https://eel.is/c++draft/basic.def.odr#14.5 :

In each such definition, corresponding names, looked up according to [basic.lookup], shall refer to the same entity, ...

int x;
inline int f() { return x; } // refers to different entities!

But there is a rule in p15:

For each such entity and for D itself, the behavior is as if there is a single entity with a single definition, including in the application of these requirements to other entities.

Therefore, the above code example is not anymore IFNDR because the behave is "as if" there is only a single definition of f? I hear that this is not the case, because the requirements still apply. So if we change f to this:

inline int f() { return []{return 0;}(); } 

If we check the requirements in p14 and then for the remainder of the spec behave as if there was only a single definition of D (which is what prior specs said), then the requirement in p14 that says this is violated and the function f becomes IFNDR:

In each such definition, except within the default arguments and default template arguments of D, corresponding lambda-expressions shall have the same closure type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions