Thread overview
[Issue 1300] New: Issues with struct in compile-time function
Jun 30, 2007
d-bugmail
Jun 30, 2007
d-bugmail
Jul 30, 2007
d-bugmail
June 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1300

           Summary: Issues with struct in compile-time function
           Product: D
           Version: 1.017
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: samukha@voliacable.com


May be related to 1204

struct Bar
{
    int x;
}

int foo()
{
    // Fails with 'Error: cannot cast int to Bar' if explicit initialization is
omitted:
    Bar b = Bar.init;

    b.x = 1;
    b = bar(b); // Error: cannot evaluate foo() at compile time

    return b.x;
}

Bar bar(Bar b)
{
    return b;
}

void main(char[][] args)
{
    static x = foo();
}


-- 

June 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1300





------- Comment #1 from samukha@voliacable.com  2007-06-30 08:41 -------
More test cases:

struct Bar
{
    int x;
}

int foo()
{
    Bar b = Bar.init;

    b.x = 100;

    for (size_t i = 0; i < b.x; i++) // b.x is the stumbling block here
    {
    }

    b.x++; // fails while b.x = b.x + 1 works

    return b.x;
}

void main(char[][] args)
{
    static x = foo();
}


-- 

July 30, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1300


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla@digitalmars.com  2007-07-30 15:48 -------
Fixed DMD 1.019 and 2.003


--