www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15425] New: std.traits.hasIndirections fails to recognize

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 puremagic.com
          Reporter: schuetzm 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.)

--
Dec 08 2015