Thread overview
[Issue 4213] New: Strange behaviour with static void[] arrays
May 20, 2010
nfxjfg@gmail.com
May 20, 2010
nfxjfg@gmail.com
May 21, 2010
Walter Bright
May 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4213

           Summary: Strange behaviour with static void[] arrays
           Product: D
           Version: 1.057
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: nfxjfg@gmail.com


--- Comment #0 from nfxjfg@gmail.com 2010-05-20 12:13:59 PDT ---
This code always worked:

struct X {
 union {
   void[] a;
   void[9] b;
 }
}

However, if you remove the union (so that a, b are direct struct members), it stops working and outputs "Error: integral constant must be scalar type, not void" (without line number information!). It also stops compiling if you remove the "a" member.

It also generates a wrong .sizeof for the struct (12 instead of 9*4). Not sure what exactly is going on.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4213



--- Comment #1 from nfxjfg@gmail.com 2010-05-20 12:16:10 PDT ---
Never mind that bit about the struct's size, b is 9 bytes, aligned on 4 = 12 bytes. Correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 20, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4213


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2010-05-20 12:35:51 PDT ---
Note that this compiles on v2.046, but it stops compiling if you remove the =void, so that problem can be by design:


void main() {
    void[1] a = void;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 21, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4213


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-05-20 22:19:19 PDT ---
improved error message with changeset 496

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