www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22777] New: stat struct in core.sys.windows.stat assumes


          Issue ID: 22777
           Summary: stat struct in core.sys.windows.stat assumes
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: duser airmail.cc

test program:

import core.sys.windows.stat;
import std.stdio;
struct X { struct_stat sb; ubyte[8] extra; }
void main()
        X x;
        stat(".", &x.sb);
        foreach (m; __traits(allMembers, struct_stat))
                writefln("%s = %s", m, __traits(getMember, x.sb, m));
        writefln("extra = %s", x.extra);

with "dmd -m32", the output looks normal

with "dmd -m32mscoff" or "dmd -m64" (same output), some of the fields are
misaligned and four bytes are written past the end of the struct

Feb 15 2022