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

[dcl.init.general] p5 wording does not seem to match the intent #4478

Closed
cpplearner opened this issue Feb 3, 2021 · 2 comments · Fixed by #4482
Closed

[dcl.init.general] p5 wording does not seem to match the intent #4478

cpplearner opened this issue Feb 3, 2021 · 2 comments · Fixed by #4482
Assignees

Comments

@cpplearner
Copy link
Contributor

[dcl.init.general]/5:

A declaration of a block variable with linkage that has an initializer is ill-formed.

IIUC the intent is to prohibit

void f() {
    extern int x = 1;
}

But it seems that the variable x is not a block variable, because it does not belong to the block scope, because the target scope of its declaration is the innermost enclosing namespace scope ([dcl.meaning.general]/(3.5)).

I think this sentence should instead talk about the immediate scope of the declaration.

cc @opensdh

@jensmaurer
Copy link
Member

jensmaurer commented Feb 3, 2021

Maybe:

A declaration D of a variable with linkage shall not have an initializer if D inhabits a block scope.

@opensdh, comments welcome.

@opensdh
Copy link
Contributor

opensdh commented Feb 9, 2021

Right; "block-scope variable" → "block variable" seemed trivially correct when we disentangled block/local variables, but of course the old terminology was imprecise and required interpretation! Oops.

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

Successfully merging a pull request may close this issue.

3 participants