Bug 23390 – value of void initialized variable is unspecified (and not subject to implementation defined behavior)

Status
NEW
Severity
normal
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-10-06T12:14:03Z
Last change time
2024-12-15T15:27:37Z
Assigned to
No Owner
Creator
kdevel
Moved to GitHub: dlang.org#3995 →

Comments

Comment #0 by kdevel — 2022-10-06T12:14:03Z
Source: https://forum.dlang.org/post/[email protected] | >> 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.
Comment #1 by elpenguino+D — 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.
Comment #2 by kdevel — 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.
Comment #3 by kdevel — 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.
Comment #4 by robert.schadek — 2024-12-15T15:27:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/3995 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB