D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23390 - value of void initialized variable is unspecified (and not subject to implementation defined behavior)
Summary: value of void initialized variable is unspecified (and not subject to impleme...
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-06 12:14 UTC by kdevel
Modified: 2024-12-15 15:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kdevel 2022-10-06 12:14:03 UTC
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.
Comment 1 elpenguino+D 2022-10-06 14:14:21 UTC
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 kdevel 2022-10-06 14:53:00 UTC
(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 kdevel 2022-10-06 14:57:39 UTC
(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 dlangBugzillaToGithub 2024-12-15 15:27:37 UTC
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