[Issue 13209] Refused union initialization

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jul 27 06:52:19 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13209

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

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

--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> ---
Introduced in: https://github.com/D-Programming-Language/dmd/pull/3400

However I think this is not a regression, because

> struct Foo {
>     union {
>         immutable static struct { double x, y; }

This line is an anonymous struct declaration with 'static' attribute, so
x and y should become immutable static field. Therefore

>         immutable double[2] v;
>     }
>     Foo bar() {
>         return Foo(y, x);
>     }
> }
> void main() {}
> 
> 
> dmd 2.066beta4 gives:
> 
> test.d(7,19): Error: more initializers than fields (1) of Foo

In git head, Foo.x and Foo.y are correctly analyzed as static fields, and Foo
has only one instance field v.

--


More information about the Digitalmars-d-bugs mailing list