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] CWG 2433: Why is "external linkage" only mentioned for inline functions & variables? #3237

Closed
cpplearner opened this issue Sep 23, 2019 · 3 comments
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.

Comments

@cpplearner
Copy link
Contributor

[basic.def.odr]/12:

There can be more than one definition of a

  • class type ([class]),
  • enumeration type ([dcl.enum]),
  • inline function or variable ([dcl.inline]) with external linkage,
  • [...]

in a program provided that each definition appears in a different translation unit, [...].

Why is "external linkage" only mentioned in the third bullet? Why isn't it required for classes and enums?

AFAIK entities with internal linkage/no linkage cannot appear in multiple translation units, so they can't have more than one definition. (There can be definitions with the same spelling, but they nonetheless define different entities.) This applies to all entities: there's no reason to special-case inline functions & variables.

@jensmaurer
Copy link
Member

Plus I think you can't have duplicate definitions with module linkage, either.

Since non-external linkage for classes and enums with more than one definition is made impossible by other rules (in particular, two definitions of internal-linkage classes wouldn't have the same name to start with; see also 6.5 [basic.link] p11), the phrasing here at most might give the wrong impression that there is permission for multiple definitions of non-external linkage types.

@jensmaurer jensmaurer added decision-required A decision of the editorial group (or the Project Editor) is required. cwg Issue must be reviewed by CWG. and removed decision-required A decision of the editorial group (or the Project Editor) is required. labels Sep 24, 2019
@jensmaurer
Copy link
Member

Editorial teleconference: This needs to go to CWG.

@cpplearner
Copy link
Contributor Author

Fixed by CWG 2433 (commit 2140e55).

@jensmaurer jensmaurer added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Jan 15, 2020
@jensmaurer jensmaurer changed the title [basic.def.odr] Why is "external linkage" only mentioned for inline functions & variables? [basic.def.odr] CWG 2433: Why is "external linkage" only mentioned for inline functions & variables? Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

No branches or pull requests

2 participants