www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1363] New: Compile-time issue with structs in 'for'

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1363

           Summary: Compile-time issue with structs in 'for'
           Product: D
           Version: 1.019
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


Related to 1300.

struct Bar
{
    int x;
}

int foo()
{
    Bar bar;

    // Error: cannot evaluate foo() at compile time
    for (bar.x = 0; bar.x < 10; bar.x++)
    {
    }

    return bar.x;
}

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


-- 
Jul 23 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1363






This one gives
'Error: cannot cast int to char[]':

struct Bar
{
    int x;
    char[] s;
}

char[] foo()
{
    Bar bar; // Works if bar is explicitly initialized.
    return bar.s;
}

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


-- 
Jul 23 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1363


bugzilla digitalmars.com changed:

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





Fixed dmd 1.021 and 2.004


-- 
Sep 28 2007