[Issue 15425] New: std.traits.hasIndirections fails to recognize nested structs

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Dec 8 13:55:13 PST 2015


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

          Issue ID: 15425
           Summary: std.traits.hasIndirections fails to recognize nested
                    structs
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schuetzm at gmx.net

import std.traits;

void foo() {
    static struct S1 {
        long a;
        void bar() { }
    }
    struct S2 {
        long a;
        void bar() { }
    }
    pragma(msg, S1.sizeof); // 8LU
    static assert(!hasIndirections!S1);  // succeeds
    pragma(msg, S2.sizeof); // 16 LU
    static assert(hasIndirections!S2);   // fails
}

The larger size of S2 clearly shows that the context pointer is included.

(Other functions in std.traits, like hasUnsharedAliasing, may need to be fixed,
too.)

--


More information about the Digitalmars-d-bugs mailing list