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

[basic.def.odr] p12 Is the definition domain isolated or union #5561

Closed
xmh0511 opened this issue Jul 12, 2022 · 4 comments
Closed

[basic.def.odr] p12 Is the definition domain isolated or union #5561

xmh0511 opened this issue Jul 12, 2022 · 4 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jul 12, 2022

[basic.def.odr] p12 says

A definition domain is a private-module-fragment or the portion of a translation unit excluding its private-module-fragment (if any).

Are all definition domains that are the same kind in different translation units considered as if they were a single definition domain? which is similar to namespaces that are defined in different translation units:

// translation unit A
namespace C{
   void fun();
}
//--------------
// translation unit B
namespace C{
   void fun(){}
}

Namespace C and function fun in translation unit A and the corresponding namespace and function in translation unit B both respectively refer to the same entity even though they are (lexically)declared in different translation units. Is the definition domain similar to it? In other words, a definition domain is a union of the same kind of definition domain of every translation unit.

It seems the intent should be that the definition domain is isolated by the translation unit. Specifically, the domain associated with private-module-fragment in TU A is a different definition domain from that associated with private-module-fragment in TU B. The same is true for the definition domain that is associated with the rest portion of a translation unit.

So, when we use the "definition domain" to phrase a rule, is it better if we give an extent to the definition domain in order to avoid over-reading? For example:
[dcl.inline] p7 says

If an inline function or variable that is attached to a named module is declared in a definition domain, it shall be defined in that domain of that translation unit.

Limit the definition domain we talk about to a single translation unit.

@jensmaurer
Copy link
Member

jensmaurer commented Jul 12, 2022

The definition domain is obviously defined per translation unit ("portion of a translation unit"); claiming that definition domains of different translation units are somehow merged is an adverse reading not support by the current wording.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jul 12, 2022

The definition domain is obviously defined per translation unit ("portion of a translation unit")

Consider the first wording in [basic.def.odr] p12

A definition domain is a private-module-fragment

This just sounds like every private-module-fragment can be merged. From this sentence, there is no given extent to which the definition domain that is talking about is in. In other words, it sounds like I say

A member is a person who has a VIP card.

So, whose member? what group? It is vague here. what I'm claiming here is to give the definition domain an extent constraint. At least, we should say

A definition domain of a translation unit is its private-module-fragment(if any) or the portion of the translation unit excluding its private-module-fragment(if any).

which means that each time we talk about the definition domain, we actually talk about the definition domain of a particular translation unit.

@jensmaurer
Copy link
Member

jensmaurer commented Jul 12, 2022

private-module-fragment is a grammar non-terminal. There's no way how those could be merged (lexically?) across translation units, given [lex.phases].

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jul 12, 2022

A definition domain of a translation unit is its private-module-fragment(if any) or the portion of the translation unit excluding its private-module-fragment(if any).

I think it may at least be an improvement to emphasize this point. This means regardless of private-module-fragment or the other portion, they are all part of the current translation unit we are talking about.

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

2 participants