December 25, 2013 [Issue 11817] New: Structs with void initialized fields get initialized anyway | ||||
|---|---|---|---|---|
| ||||
https://d.puremagic.com/issues/show_bug.cgi?id=11817 Summary: Structs with void initialized fields get initialized anyway Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bugzilla@digitalmars.com --- Comment #0 from Walter Bright <bugzilla@digitalmars.com> 2013-12-25 13:38:54 PST --- ----- Code ----- struct S { int a; ubyte[100] b = void; } void test() { S s; s.a = 3; } --------------- The output: enter 068h,0 push ESI push EDI mov ESI,offset FLAT:_D4foo21S6__initZ lea EDI,-068h[EBP] mov ECX,01Ah rep movsd mov dword ptr -068h[EBP],3 pop EDI pop ESI leave ret I.e. the field s.b is initialized. While not pedantically a bug, this substantially interferes with performance tuning. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- | ||||
December 25, 2013 [Issue 11817] Structs with void initialized fields get initialized anyway | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | https://d.puremagic.com/issues/show_bug.cgi?id=11817 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim@maxim-fomin.ru --- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-12-25 13:55:30 PST --- Main question is what to do with aggregate members initialized to void. Currently default initialized instances have fields which are zeroed. T.init value is also zeroed, but both behaviors are under question. I think current practice should be reviewed because the issue tends to pop up instantly in NG in bugzilla. Meanwhile, recent discussions: http://d.puremagic.com/issues/show_bug.cgi?id=11331 https://d.puremagic.com/issues/show_bug.cgi?id=10643 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply