www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13238] New: getMember trait changes function linkage

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

          Issue ID: 13238
           Summary: getMember trait changes function linkage
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: vlevenfeld gmail.com

struct Foo
{
    extern (C) void function (int*) func;
}
struct Bar
{
    static string code ()
    {
        string code;

        foreach (symbol; __traits (allMembers, typeof(this)))
            static if (is(typeof(__traits (getMember, typeof(this), symbol))))
                {}

        return code;
    }

    extern (C) void function (int*) func;

    mixin(code);
}
struct Baz
{
    static string code ()
    {
        string code;

        foreach (symbol; __traits (allMembers, typeof(this)))
            static if (is(typeof(__traits (getMember, typeof(this), symbol))))
                {}

        return code;
    }

    mixin(code);

    extern (C) void function (int*) func;
}

void main () 
{
    static assert (functionLinkage!(typeof(Foo.func)) == `C`);
    static assert (functionLinkage!(typeof(Bar.func)) == `C`);
    static assert (functionLinkage!(typeof(Baz.func)) == `D`); // BUG why?
}

--
Aug 01 2014