Source

gdc / gdc.test / runnable / test48.d

// EXTRA_SOURCES: imports/test48a.d
// PERMUTE_ARGS:

import std.stdio;
import imports.test48a;

void main()
{
    S s;
    auto i = s.tupleof[0] + s.tupleof[1] + s.tupleof[2];
    printf("i = %d\n", i);
    assert(i == 6);

    auto t = s.tupleof;
    i = t[0] + t[1] + t[2];
    printf("i = %d\n", i);
    assert(i == 6);

    printf("a = %d %d %d\n", S.tupleof.offsetof);
    auto o = S.tupleof.offsetof;
    assert(o[0] == 0);
    assert(o[1] == 4);
    assert(o[2] == 8);
    printf("a = %d %d %d\n", S.tupleof[0].offsetof, S.tupleof[1].offsetof, S.tupleof[2].offsetof);
    assert(S.tupleof[0].offsetof == 0);
    assert(S.tupleof[1].offsetof == 4);
    assert(S.tupleof[2].offsetof == 8);

    auto offset0 = cast(void*)&s.tupleof[0] - cast(void*)&s;
    printf("offset0 = %d\n", offset0);
    assert(offset0 == 0);

    auto offset1 = cast(void*)&s.tupleof[1] - cast(void*)&s;
    printf("offset1 = %d\n", offset1);
    assert(offset1 == 4);

    auto offset2 = cast(void*)&s.tupleof[2] - cast(void*)&s;
    printf("offset2 = %d\n", offset2);
    assert(offset2 == 8);

    int t1[S.tupleof.offsetof[1]];
    assert(t1.length == 4);
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.