[Issue 9566] Cannot use struct .init when it contains a static array initialized from a single element.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 21 22:57:52 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9566


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #1 from monarchdodra at gmail.com 2013-02-21 22:57:51 PST ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list