D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10585 - Structs in unittest / functions shouldn't have frame pointer unless necessary
Summary: Structs in unittest / functions shouldn't have frame pointer unless necessary
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: TDPL
Depends on:
Blocks:
 
Reported: 2013-07-09 11:21 UTC by hsteoh
Modified: 2024-12-13 18:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description hsteoh 2013-07-09 11:21:21 UTC
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.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:09:01 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18623

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB