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

value of void initialized variable is unspecified (and not subject to implementation defined behavior) #3995

Open
dlangBugzillaToGithub opened this issue Oct 6, 2022 · 3 comments

Comments

@dlangBugzillaToGithub
Copy link

kdevel reported this on 2022-10-06T12:14:03Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=23390

CC List

Description

Source: https://forum.dlang.org/post/ylnkspqzfsnrvojmtqwm@forum.dlang.org

| >> I got the answer thanks to IRC chat: https://dlang.org/spec/declaration.html#void_init
| > Quote:
| >
| >    Implementation Defined: If a void initialized variable's value is used
| >    before it is set, its value is implementation defined.
| >
| > Shouldn't this read
| >
| >    Unspecified Value: If a void initialized variable's value is used
| >    before it is set, its value is unspecified.
| 
| Yes, it should. Many of the contributors to the D spec are not very well
| versed in the precise details of these terms, so mistakes like this
| occasionally slip through.
@dlangBugzillaToGithub
Copy link
Author

elpenguino+D commented on 2022-10-06T14:14:21Z

The current wording allows compilers to put values like NaNs in void initialized variables, to make it easier to catch cases where the value is used before it's set. This change would forbid that, and I don't see any benefit to doing so.

@dlangBugzillaToGithub
Copy link
Author

kdevel commented on 2022-10-06T14:53:00Z

(In reply to elpenguino+D from comment #1)
> The current wording allows compilers to put values like NaNs in void
> initialized variables, to make it easier to catch cases where the value is
> used before it's set. This change would forbid that, and I don't see any
> benefit to doing so.

Sorry for the "UB" in the subject. The documentation says that the value of a void initialized variable is "implementation defined". I corrected the subject.

"implementation defined" means that the implementation documentation ("dmd spec") says what value a variable assumes. I could not find such a documentation.

As far as I recall the terminology for unknown but valid values is "unspecified value". Hence this issue.

@dlangBugzillaToGithub
Copy link
Author

kdevel commented on 2022-10-06T14:57:39Z

(In reply to kdevel from comment #2)
> As far as I recall the terminology for unknown but valid values is
> "unspecified value". Hence this issue.

Please delete the "but valid". My last paragraph should read:

   As far as I recall the terminology for unknown values
   is "unspecified value". Hence this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant