Thread overview
[Issue 9566] New: Cannot use struct .init when it contains a static array initialized from a single element.
Feb 22, 2013
Marco Leise
[Issue 9566] Regression (2.062): Cannot use struct .init when it contains a static array initialized from a single element.
Feb 24, 2013
Kenji Hara
Feb 25, 2013
Kenji Hara
February 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566

           Summary: Cannot use struct .init when it contains a static
                    array initialized from a single element.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: Marco.Leise@gmx.de


--- Comment #0 from Marco Leise <Marco.Leise@gmx.de> 2013-02-21 21:26:11 PST ---
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]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566


monarchdodra@gmail.com changed:

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


--- Comment #1 from monarchdodra@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: -------
February 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566



--- Comment #2 from monarchdodra@gmail.com 2013-02-21 23:03:44 PST ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-24 02:25:00 PST ---
https://github.com/D-Programming-Language/dmd/pull/1688

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566



--- Comment #4 from github-bugzilla@puremagic.com 2013-02-24 14:19:30 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566



--- Comment #5 from github-bugzilla@puremagic.com 2013-02-24 14:21:22 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9566


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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