Thread overview
[Issue 15205] Incorrect struct init via union array
Oct 15, 2015
ag0aep6g@gmail.com
Oct 27, 2015
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
October 15, 2015
https://issues.dlang.org/show_bug.cgi?id=15205

ag0aep6g@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--
October 27, 2015
https://issues.dlang.org/show_bug.cgi?id=15205

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thecybershadow@gmail.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=11269

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Note: before https://github.com/D-Programming-Language/dmd/pull/2681 this caused a compile-time error:

test.d(29): Error: duplicate union initialization for v

Perhaps this should still result in an error due to incomplete implementation of unions in CTFE.

--
July 21, 2019
https://issues.dlang.org/show_bug.cgi?id=15205

skocznymr@gmail.com changed:

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

--- Comment #2 from skocznymr@gmail.com ---
Encountered what seems to be the same issue. Reproduces on DMD 2.084.0 and LDC 1.13.0

import std.stdio;

struct Foo
{
    static Foo initializedFoo()
    {
        Foo x;
        x.a_array[0] = 1;
        return x;
    }

    union
    {
        float a;
        float[1] a_array;
    }
}

Foo bar = Foo.initializedFoo();

void main()
{
    writeln(bar.a);
    writeln(bar.a_array);
}

returns nan [nan] instead of 1 [1]

--
November 24, 2019
https://issues.dlang.org/show_bug.cgi?id=15205

--- Comment #3 from skocznymr@gmail.com ---
*** Issue 18313 has been marked as a duplicate of this issue. ***

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15205

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--