Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structs in unittest / functions shouldn't have frame pointer unless necessary #18623

Open
dlangBugzillaToGithub opened this issue Jul 9, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

hsteoh reported this on 2013-07-09T11:21:21Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=10585

Description

CODE:

------snip------
import std.stdio;

void listMembers(T)() {
        writefln("Size of %s is %d", T.stringof, T.sizeof);
        foreach (field; __traits(allMembers, T)) {
                writefln("\t%s", field);
        }
}

void main() {
        int y=1;
        
        struct S1 {
                int x;
        }
        static struct S2 {
                int x;
                bool opEquals() { return true; }
        }
        struct S3 {
                int x;
                bool opEquals() { return true; }
        }
        struct S4 {
                int x;
                bool opEquals() { return y==1; }
        }
        
        listMembers!S1();
        listMembers!S2();
        listMembers!S3();
        listMembers!S4();
}
------snip------

OUTPUT:
------snip------
Size of S1 is 4
        x
Size of S2 is 4
        x
        opEquals
Size of S3 is 16
        x
        opEquals
        this
Size of S4 is 16
        x
        opEquals
        this
------snip------

S3 is identical to S2 (except for the 'static' qualifier); DMD should not insert the frame pointer since it's not needed.

According to TDPL, the frame pointer is only inserted where needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant