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.scope.pdecl]/1 Example is outdated #3578

Closed
languagelawyer opened this issue Dec 25, 2019 · 1 comment · Fixed by #3580
Closed

[basic.scope.pdecl]/1 Example is outdated #3578

languagelawyer opened this issue Dec 25, 2019 · 1 comment · Fixed by #3580
Assignees

Comments

@languagelawyer
Copy link
Contributor

languagelawyer commented Dec 25, 2019

From https://stackoverflow.com/questions/59442521/use-of-variable-in-own-initializer
After the resolution of CWG2256¹ changed the rules of an object lifetime start, unsigned char x = x; no longer initializes x with its own indeterminate value as the Example in [basic.scope.pdecl]/1 says, but triggers undefined behavior, because the initializer accesses the object whose lifetime has not started yet (because variable initialization hasn't completed).


  1. Which, if ignore references, kinda mixes variables with objects…
@jensmaurer
Copy link
Member

jensmaurer commented Dec 25, 2019

So, the definition of "vacuous initialization" has changed, and that means "unsigned char x = x" no longer has vacuous initialization, thus the glvalue "x" is used to access an object whose lifetime has not yet begun, which is undefined behavior. If that's unintended (is it?), that doesn't seem to be editorial at all to me.

If the change in semantics here is intended, fixing the example is indeed editorial.

Asked CWG: http://lists.isocpp.org/core/2019/12/8017.php

@jensmaurer jensmaurer added the cwg Issue must be reviewed by CWG. label Dec 25, 2019
@jensmaurer jensmaurer removed the cwg Issue must be reviewed by CWG. label Dec 26, 2019
@jensmaurer jensmaurer self-assigned this Dec 26, 2019
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.

2 participants