Skip to content

[bugfix] Initialize uncertain field value - #2454

Merged
quickfur merged 1 commit into
dlang:masterfrom
9rnsr:fix13321
Aug 22, 2014
Merged

quickfur merged 1 commit into
dlang:masterfrom
9rnsr:fix13321

Conversation

@9rnsr

@9rnsr 9rnsr commented Aug 22, 2014

Copy link
Copy Markdown
Contributor

Compiler does not guarantee the initial value of void-initialized field. So this is definitely a bug in Phobos code.

@quickfur

Copy link
Copy Markdown
Member

LGTM

@monarchdodra

Copy link
Copy Markdown
Collaborator

Why are these fields declared void to begin with? I makes no difference if you actually do call the constructor, but gives you unspecified (undefined?) behavior if you try to use without initializing.

Arguably, it could even be more expensive, since it requires actual runtime work in the constructor, which could be done by .init anyways.

Well, LGTM anyways, but I wish we'd avoid void fields in structs. It makes little sense to me. If you want void, you just void the entire struct itself on declaration.

@quickfur

Copy link
Copy Markdown
Member

Auto-merge toggled on

quickfur pushed a commit that referenced this pull request Aug 22, 2014
[bugfix] Initialize uncertain field value
@quickfur
quickfur merged commit a358a6b into dlang:master Aug 22, 2014
@9rnsr
9rnsr deleted the fix13321 branch August 24, 2014 04:44
jmdavis pushed a commit to jmdavis/phobos that referenced this pull request Jul 15, 2026
Support nothrow new
merged-on-behalf-of: Nicholas Wilson <[email protected]>
jmdavis pushed a commit to jmdavis/phobos that referenced this pull request Jul 15, 2026
[spec/function.dd] Add scope parameter section
merged-on-behalf-of: Nicholas Wilson <[email protected]>
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 this pull request may close these issues.

3 participants