Thread overview
[Issue 15604] [REG2.070] std.array.array of structs with template opAssign and default initialised 'new'ed class member
[Issue 15604] std.array.array of structs with template opAssign and default initialised "new"ed class member.
Jan 25, 2016
John Colvin
Jan 26, 2016
John Colvin
Jan 29, 2016
David Nadlinger
Jan 30, 2016
John Colvin
[Issue 15604] std.array.array of structs with template opAssign and default initialised 'new'ed class member
Apr 15, 2016
Walter Bright
Oct 28, 2016
Martin Krejcirik
Jul 05, 2017
Vladimir Panteleev
January 25, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

John Colvin <john.loughran.colvin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.array.array on nested   |std.array.array of structs
                   |structs, weird corner case. |with template opAssign and
                   |                            |default initialised "new"ed
                   |                            |class member.

--
January 26, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

--- Comment #1 from John Colvin <john.loughran.colvin@gmail.com> ---
The problem comes from a deeper issue with static initialisers with indirections, which are just a nightmare.

Nonetheless, here's the fix: https://github.com/D-Programming-Language/phobos/pull/3952

--
January 29, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

David Nadlinger <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@klickverbot.at

--- Comment #2 from David Nadlinger <code@klickverbot.at> ---
As I pointed out in the GitHub issue, I'm not convinced that this is a regression. Isn't it just an accepts-invalid bug in the compiler that the struct declaration is considered valid in the first place?

>From looking at the codegen, I find it hard to imagine that the current
behavior (a single implicitly-shared object instance) would be what the user
would expect.

--
January 30, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

--- Comment #3 from John Colvin <john.loughran.colvin@gmail.com> ---
(In reply to David Nadlinger from comment #2)
> As I pointed out in the GitHub issue, I'm not convinced that this is a regression. Isn't it just an accepts-invalid bug in the compiler that the struct declaration is considered valid in the first place?
> 
> From looking at the codegen, I find it hard to imagine that the current behavior (a single implicitly-shared object instance) would be what the user would expect.


I agree and have since deleted all such things from the codebase I was working on. I also hit some weird linker errors with them that I was unable to minimise examples for, so good riddance.

On the topic of static initialisers with mutable indirections, what about these:

struct A
{
    int[] arr = [1, 2, 3];
}

or this:

Object globalSingleton;
struct B
{
    Object o = globalSingleton;
}

--
April 15, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com
            Summary|std.array.array of structs  |std.array.array of structs
                   |with template opAssign and  |with template opAssign and
                   |default initialised "new"ed |default initialised 'new'ed
                   |class member.               |class member

--
October 28, 2016
https://issues.dlang.org/show_bug.cgi?id=15604

Martin Krejcirik <mk@krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.array.array of structs  |[REG2.070] std.array.array
                   |with template opAssign and  |of structs with template
                   |default initialised 'new'ed |opAssign and default
                   |class member                |initialised 'new'ed class
                   |                            |member

--
July 05, 2017
https://issues.dlang.org/show_bug.cgi?id=15604

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net
         Resolution|---                         |INVALID

--- Comment #4 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to John Colvin from comment #3)
> On the topic of static initialisers with mutable indirections, what about these:

I believe all of those are invalid and should not compile.

I filed issue 17604 for this (even though it's probably a duplicate of another issue filed somewhere), so I think we can now close this one.

--