Bug 9566 – Regression (2.062): Cannot use struct .init when it contains a static array initialized from a single element.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-21T21:26:00Z
Last change time
2013-02-25T04:56:48Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
Marco.Leise

Comments

Comment #0 by Marco.Leise — 2013-02-21T21:26:11Z
Seeing is believing. Reduced test case: ____________________ import core.stdc.stdlib; struct SZDDFile { ExpandData* pExpandData = null; struct ExpandData { ubyte[4096] window = 0; } void open() { pExpandData = cast(ExpandData*) malloc (ExpandData.sizeof); *pExpandData = ExpandData.init; } } ____________________ Error: cannot implicitly convert expression (cast(ubyte)0u) of type ubyte to ubyte[4096LU]
Comment #1 by monarchdodra — 2013-02-21T22:57:51Z
(In reply to comment #0) > Seeing is believing. Reduced test case: > ____________________ > > import core.stdc.stdlib; > > struct SZDDFile > { > ExpandData* pExpandData = null; > > struct ExpandData > { > ubyte[4096] window = 0; > } > > void open() > { > pExpandData = cast(ExpandData*) malloc (ExpandData.sizeof); > *pExpandData = ExpandData.init; > } > } > ____________________ > > Error: cannot implicitly convert expression (cast(ubyte)0u) of type ubyte to > ubyte[4096LU] It's not about the surrounding code, but rather, whether or not you use the .init property. Reduced test case: //---- struct ExpandData { ubyte[4096] window = 0; } void main() { ExpandData a; auto b = ExpandData.init; //Comment me. } //---- Works in 2.061, so is a regression.
Comment #2 by monarchdodra — 2013-02-21T23:03:44Z
(In reply to comment #1) > It's not about the surrounding code, but rather, whether or not you use the > .init property. Right, came from the message boards, where you said "I didn't imagine it would depend on any surrounding code", and didn't notice you had already pinned it in the title. Please ignore that sentence then.
Comment #3 by k.hara.pg — 2013-02-24T02:25:00Z
Comment #4 by github-bugzilla — 2013-02-24T14:19:30Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ac3de50bcff047b86ff8fe8778f00e8f4845315c fix Issue 9566 - Cannot use struct .init when it contains static array initialized from a single element. https://github.com/D-Programming-Language/dmd/commit/f5eb6d5f9684ff6276cdbc52919b5b877d36d72d Merge pull request #1688 from 9rnsr/fix9566 [REG 2.062] Issue 9566 - Cannot use struct .init when it contains static array initialized from a single element.
Comment #5 by github-bugzilla — 2013-02-24T14:21:22Z
Commit pushed to 2.062 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/e8521cb9e23119a50a6d97af0f5d9e6e5e16f8bf Merge pull request #1688 from 9rnsr/fix9566 [REG 2.062] Issue 9566 - Cannot use struct .init when it contains static array initialized from a single element.