www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7727] New: Immutable union instantiations too

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727

           Summary: Immutable union instantiations too
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



struct Foo1 {
    ushort bar2;
}
struct Foo2 {
    union  {
        ubyte[2] bar1;
        ushort bar2;
    }
}
void main() {
    immutable Foo1 foo1 = { bar2: 100 }; // OK
    immutable Foo2 foo2 = { bar2: 100 }; // error
}



DMD 2.059 gives:

test.d(12): Error: variable test.main.foo2 is not a static and cannot have
static initializer


(Maybe it's just a well known problem of unions not supported in CTFE?)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 18 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727


Denis Shelomovskij <verylonglogin.reg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg gmail.com
           Platform|x86                         |All
            Summary|Immutable union             |Allso "static initializer"
                   |instantiations too          |for non-static unions too
         OS/Version|Windows                     |All



18:12:58 MSD ---
The issue has nothing to do with immutability:
---
struct S { int i; double d; }
union U { int i; double d; }

void main()
{
    S s = { d: 5 }; // OK
    U u = { d: 5 }; // Error: variable main.main.u is not a static and cannot
have static initializer
}
---

By the way, docs don't mention one can do such "static initialization" for
non-static structs or unions. Anyway, the difference should be obliterated by
allowing/disallowing both.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727


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

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



https://github.com/D-Programming-Language/dmd/pull/2605

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Allso "static initializer"  |"static initializer" for
                   |for non-static unions too   |non-static unions too



Changed issue title again.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8ee7e869b44f0cb4f72d6d0609cdbfa96caae002
fix Issue 7727 - "static initializer" for non-static unions too

https://github.com/D-Programming-Language/dmd/commit/a35bd9efc2957eaa7ddea47b41d87c388bdde4b9


Issue 7727 - "static initializer" for non-static unions too

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 05 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7727


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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